This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/9804] pthread_exit from main thread: poor semantics, potential tty session lockup.
- From: "kkylheku at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 31 Jan 2009 07:01:44 -0000
- Subject: [Bug nptl/9804] pthread_exit from main thread: poor semantics, potential tty session lockup.
- References: <20090131031846.9804.kkylheku@gmail.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From kkylheku at gmail dot com 2009-01-31 07:01 -------
(In reply to comment #1)
> The tasks of the other threads terminate in ten seconds, but
> the main one must be killed by SIGKILL, and control of the tty
> cannot be wrestled away from it.
This statement is wrong. In fact, the threads other than main do not
terminate. They also stick around. Somehow, the Ctrl-Z signal prevents their
termination.
The main thread runs all the way through the do_exit routine in the kernel,
and makes the final schedule call, turning into a defunct process. (I added
traces to do_exit).
The Ctrl-Z hang seems to be causing the othread threads to be stuck in the
kernel function do_signal_stop, according to what is reported
in /proc/<pid>/wchan.
The repro program is this:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#define NUM_THREADS 5
void *task(void *a)
{
sleep(10);
pthread_exit(NULL);
}
int
main(int argc, char *argv[])
{
pthread_t thr[NUM_THREADS];
int i;
for (i = 0; i < NUM_THREADS; i++) {
if (pthread_create(&thr[i], NULL, task, 0) != 0) {
fprintf(stderr, "pthread_create failed\n");
return EXIT_FAILURE;
}
}
pthread_exit(NULL);
}
--
http://sourceware.org/bugzilla/show_bug.cgi?id=9804
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.