summaryrefslogtreecommitdiff
path: root/test/signal/sigchld.c
blob: 05f4d1594686a7a1ee2e4b89b8a74fb83f21b638 (plain)
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
#include <stdlib.h>
#include <stdio.h>
#include <sys/signal.h>
#include <unistd.h>

void test_handler(int signo) 
{
    fprintf(stderr, "caught signo: %d\n", signo);
}


int main(void) 
{
    int count = 0;
    struct sigaction siga;
    static sigset_t sigset;

    sigfillset(&sigset);

    siga.sa_handler = test_handler;
    siga.sa_mask = sigset;
    siga.sa_flags = 0;

    if (0 != sigaction(SIGCHLD, &siga, (struct sigaction *)NULL)) {
	fprintf(stderr, "ack!");
    }
    printf("give me a SIGCHLD\n");

    for(;;) {
	sleep(10);
	printf("after sleep %d\n", ++count);
    }

    printf("after loop\n");

    return 0;
}