xref: /openbsd-src/regress/lib/libpthread/signals/ignore_sigchild/ignore_sigchild.c (revision 534084640310a3b73784adb5e68a3695b1c4a21c)
1 /*	$OpenBSD: ignore_sigchild.c,v 1.3 2016/03/17 19:40:43 krw Exp $	*/
2 /*
3  * Federico G. Schwindt <fgsch@openbsd.org>, 2011. Public Domain.
4  */
5 #include <sys/types.h>
6 #include <sys/wait.h>
7 #include <unistd.h>
8 #include <signal.h>
9 #include "test.h"
10 
11 int
main(int argc,char ** argv)12 main(int argc, char **argv)
13 {
14 	int status;
15 	pid_t pid;
16 
17 	ASSERT(signal(SIGCHLD, SIG_IGN) != SIG_ERR);
18 
19 	switch ((pid = fork())) {
20 	case -1:
21 		PANIC("fork");
22 	case 0:
23 		execl("/usr/bin/false", "false", (char *)NULL);
24 		PANIC("execlp");
25 	default:
26 		break;
27 	}
28 
29 	CHECKe(alarm(2));
30 	ASSERT(wait(&status) == -1);
31 	ASSERT(errno == ECHILD);
32 	SUCCEED;
33 }
34