This is the mail archive of the gdb@sources.redhat.com 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


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

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