File: sigkill.c

package info (click to toggle)
valgrind 1%3A3.3.1-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 34,452 kB
  • ctags: 27,778
  • sloc: ansic: 234,398; sh: 14,186; xml: 11,662; perl: 4,410; asm: 3,135; makefile: 3,011; exp: 625; cpp: 255; haskell: 195
file content (42 lines) | stat: -rw-r--r-- 987 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>

static void
abend (int sig)
{
  printf ("Abended on signal %d\n", sig);
  exit (2);
}

int
main (void)
{
  struct sigaction  sa;

  int i;
  int rc;
  for (i = 1; i <= 65; i++) {
     // skip signals 63 and 64: some systems say "warning, ignored attempt
     // to catch 32 because it's used internally by Valgrind", others say
     // "invalid argument".
     if (i == 63 || i == 64) {
        continue;       
     }                  // different systems
     sa.sa_flags   = 0;
     sigemptyset( &sa.sa_mask );
     sa.sa_handler = abend;
     fprintf(stderr,"setting signal %d: ", i);
     rc = sigaction (i /*SIGKILL*/, &sa, NULL);
     if (rc) perror ("");
     else fprintf(stderr,"Success\n");
     fprintf(stderr,"getting signal %d: ", i);
     rc = sigaction (i /*SIGKILL*/, NULL, &sa);
     if (rc) perror ("");
     else fprintf(stderr,"Success\n");
     fprintf(stderr,"\n");
  }
  return 0;
}