thread cannot stop himself
Nicolas Vignal
nicolas.vignal@netline.fr
Thu Feb 8 05:58:00 GMT 2001
Hello
I join a sample program with a thread who try to stop himself with a SIGSTOP.
( I know that is not the best way to do that ;-)
It works fine in command line but not under gdb.
gdb receive the signal and the flag pass to program is yes. But the thread
never stop.
Any idea of what happened ?
Regards
Nicolas
I'am using a Linux RedHat 6.2 with insight 20010202
#include <stdio.h>
#include <pthread.h>
#include <signal.h>
int function(void)
{
printf("I want to stop this thread\n");
pthread_kill(pthread_self(), SIGSTOP);
while(1){
printf("Why it's not working ?\n");
}
}
int main(int argc, char *argv[])
{
pthread_t threadID=-1;
pthread_create(&threadID, NULL, function, NULL);
while(1);
return 0;
}
(gdb) run
Starting program: /home/tsc/essai/stopthread
[New Thread 1024 (runnable)]
[New Thread 2049 (runnable)]
[New Thread 1026 (runnable)]
Program received signal SIGSTOP, Stopped (signal).
[Switching to Thread 1026 (runnable)]
0x4004dd41 in __kill () from /lib/libc.so.6
(gdb) handle SIGSTOP
Signal Stop Print Pass to program Description
SIGSTOP Yes Yes Yes Stopped (signal)
(gdb) c
Continuing.
After I can see "Why it's not working ?" in loop
More information about the Gdb
mailing list