diff options
Diffstat (limited to 'test/signal/sigchld.c')
-rw-r--r-- | test/signal/sigchld.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/signal/sigchld.c b/test/signal/sigchld.c new file mode 100644 index 000000000..05f4d1594 --- /dev/null +++ b/test/signal/sigchld.c @@ -0,0 +1,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; +} + |