1 /* $NetBSD: sigchld.c,v 1.6 2006/05/10 19:07:22 mrg Exp $ */
3 #include <sys/ucontext.h>
5 #include <sys/resource.h>
17 handler(int signo
, siginfo_t
*info
, void *ptr
)
21 printf("info=%p\n", info
);
22 printf("ptr=%p\n", ptr
);
23 printf("si_signo=%d\n", info
->si_signo
);
24 printf("si_errno=%d\n", info
->si_errno
);
25 printf("si_code=%d\n", info
->si_code
);
26 printf("si_uid=%d\n", info
->si_uid
);
27 printf("si_pid=%d\n", info
->si_pid
);
28 printf("si_status=%d\n", info
->si_status
);
29 printf("si_utime=%d\n", info
->si_utime
);
30 printf("si_stime=%d\n", info
->si_stime
);
33 assert(info
->si_code
== code
);
34 assert(info
->si_signo
== SIGCHLD
);
35 assert(info
->si_uid
== getuid());
36 assert(info
->si_pid
== child
);
37 if (WIFEXITED(info
->si_status
))
38 assert(WEXITSTATUS(info
->si_status
) == status
);
39 else if (WIFSTOPPED(info
->si_status
))
40 assert(WSTOPSIG(info
->si_status
) == status
);
41 else if (WIFSIGNALED(info
->si_status
))
42 assert(WTERMSIG(info
->si_status
) == status
);
46 sethandler(void (*action
)(int, siginfo_t
*, void *))
49 sa
.sa_flags
= SA_SIGINFO
;
50 sa
.sa_sigaction
= action
;
51 sigemptyset(&sa
.sa_mask
);
52 sigaction(SIGCHLD
, &sa
, NULL
);
63 switch ((child
= fork())) {
82 switch ((child
= fork())) {
102 switch ((child
= fork())) {
110 kill(child
, SIGPIPE
);
120 (void)getrlimit(RLIMIT_CORE
, &rlim
);
121 rlim
.rlim_cur
= rlim
.rlim_max
;
122 (void)setrlimit(RLIMIT_CORE
, &rlim
);
125 sigaddset(&set
, SIGCHLD
);
126 sigprocmask(SIG_BLOCK
, &set
, NULL
);