Home | History | Annotate | Download | only in tests
      1 
      2 #include <errno.h>
      3 #include <stdio.h>
      4 #include <signal.h>
      5 #include <stdlib.h>
      6 
      7 static void
      8 abend (int sig)
      9 {
     10   printf ("Abended on signal %d\n", sig);
     11   exit (2);
     12 }
     13 
     14 int
     15 main (void)
     16 {
     17   struct sigaction  sa;
     18 
     19   int i;
     20   int rc;
     21   for (i = 1; i <= 65; i++) {
     22      // Skip signals 32 and 33, since these are used by LinuxThreads. Some
     23      // glibc versions do not invoke the sigaction system call for these
     24      // signals.
     25      // skip signals 63 and 64: some systems say "warning, ignored attempt
     26      // to catch 32 because it's used internally by Valgrind", others say
     27      // "invalid argument".
     28      if (i == 32 || i == 33 || i == 63 || i == 64) {
     29         continue;
     30      }                  // different systems
     31      sa.sa_flags   = 0;
     32      sigemptyset( &sa.sa_mask );
     33      sa.sa_handler = abend;
     34      fprintf(stderr,"setting signal %d: ", i);
     35      rc = sigaction (i /*SIGKILL*/, &sa, NULL);
     36      if (rc) perror ("");
     37      else fprintf(stderr,"Success\n");
     38      fprintf(stderr,"getting signal %d: ", i);
     39      rc = sigaction (i /*SIGKILL*/, NULL, &sa);
     40      if (rc) perror ("");
     41      else fprintf(stderr,"Success\n");
     42      fprintf(stderr,"\n");
     43   }
     44   return 0;
     45 }
     46