1#include <assert.h>
2#include <signal.h>
3#include <stdio.h>
4#include <unistd.h>
5#include <sys/wait.h>
6
7void handler(int signo) {
8 printf(format: "SIGCHLD\n");
9}
10
11int main() {
12 void *ret = signal(SIGINT, handler: handler);
13 assert (ret != SIG_ERR);
14
15 pid_t child_pid = fork();
16 assert (child_pid != -1);
17
18 if (child_pid == 0) {
19 sleep(seconds: 1);
20 _exit(status: 14);
21 }
22
23 printf(format: "signo = %d\n", SIGCHLD);
24 printf(format: "code = %d\n", CLD_EXITED);
25 printf(format: "child_pid = %d\n", child_pid);
26 printf(format: "uid = %d\n", getuid());
27 pid_t waited = wait(NULL);
28 assert(waited == child_pid);
29
30 return 0;
31}
32

source code of lldb/test/Shell/Commands/Inputs/sigchld.c