File: test-unsigaction.c

package info (click to toggle)
aflplusplus 4.21c-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,496 kB
  • sloc: ansic: 110,361; cpp: 16,725; sh: 4,855; python: 3,793; makefile: 963; javascript: 515; java: 43; sql: 3; xml: 1
file content (31 lines) | stat: -rw-r--r-- 768 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
#include <signal.h>          /* sigemptyset(), sigaction(), kill(), SIGUSR1 */
#include <stdlib.h>                                               /* exit() */
#include <unistd.h>                                             /* getpid() */
#include <errno.h>                                                 /* errno */
#include <stdio.h>                                             /* fprintf() */

static void mysig_handler(int sig) {

  exit(2);

}

int main() {

  /* setup sig handler */
  struct sigaction sa;
  sa.sa_handler = mysig_handler;
  sigemptyset(&sa.sa_mask);
  sa.sa_flags = 0;
  if (sigaction(SIGCHLD, &sa, NULL)) {

    fprintf(stderr, "could not set signal handler %d, aborted\n", errno);
    exit(1);

  }

  kill(getpid(), SIGCHLD);
  return 0;

}