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