Home | History | Annotate | Line # | Download | only in c
      1  1.1  christos /* Check that TRT happens when trying to IGN an non-ignorable signal, more than one thread.
      2  1.1  christos #progos: linux
      3  1.1  christos #cc: additional_flags=-pthread
      4  1.1  christos #xerror:
      5  1.1  christos #output: Exiting pid 42 due to signal 9\n
      6  1.1  christos #output: program stopped with signal 4 (*).\n
      7  1.1  christos */
      8  1.1  christos 
      9  1.1  christos #include <stdlib.h>
     10  1.1  christos #include <stddef.h>
     11  1.1  christos #include <stdio.h>
     12  1.1  christos #include <unistd.h>
     13  1.1  christos #include <pthread.h>
     14  1.1  christos #include <sys/types.h>
     15  1.1  christos #include <signal.h>
     16  1.1  christos 
     17  1.1  christos static void *
     18  1.1  christos process (void *arg)
     19  1.1  christos {
     20  1.1  christos   while (1)
     21  1.1  christos     sched_yield ();
     22  1.1  christos   return NULL;
     23  1.1  christos }
     24  1.1  christos 
     25  1.1  christos int main (void)
     26  1.1  christos {
     27  1.1  christos   pthread_t th_a;
     28  1.1  christos   signal (SIGKILL, SIG_IGN);
     29  1.1  christos   if (pthread_create (&th_a, NULL, process, (void *) "a") == 0)
     30  1.1  christos     kill (getpid (), SIGKILL);
     31  1.1  christos   printf ("xyzzy\n");
     32  1.1  christos   exit (0);
     33  1.1  christos }
     34