This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

thread cannot stop himself


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 ?



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);
   printf("Why it's not working ?\n");

int main(int argc, char *argv[])

  pthread_t threadID=-1;
  pthread_create(&threadID, NULL, function, NULL);

  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/

(gdb) handle SIGSTOP
Signal        Stop	Print	Pass to program	Description
SIGSTOP       Yes	Yes	Yes		Stopped (signal)

(gdb) c

After I can see "Why it's not working ?" in loop

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]