]>
git.saurik.com Git - apple/xnu.git/blob - tests/sigchld_return.c
7 #include <darwintest.h>
9 T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
11 static int exitcode
= 0x6789BEEF;
15 handler(int sig
, siginfo_t
*sip
, __unused
void *uconp
)
17 /* Should handle the SIGCHLD signal */
18 T_ASSERT_EQ_INT(sig
, SIGCHLD
, "Captured signal returns 0x%x, expected SIGCHLD (0x%x).", sig
, SIGCHLD
);
19 T_QUIET
; T_ASSERT_NOTNULL(sip
, "siginfo_t returned NULL but should have returned data.");
20 T_ASSERT_EQ_INT(sip
->si_code
, CLD_EXITED
, "si_code returns 0x%x, expected CLD_EXITED (0x%x).", sip
->si_code
, CLD_EXITED
);
21 T_ASSERT_EQ_INT(sip
->si_status
, exitcode
, "si_status returns 0x%08X, expected the child's exit code (0x%08X).", sip
->si_status
, exitcode
);
26 T_DECL(sigchldreturn
, "checks that a child process exited with an exitcode returns correctly to parent", T_META_CHECK_LEAKS(false))
31 act
.sa_sigaction
= handler
;
32 act
.sa_flags
= SA_SIGINFO
;
34 /* Set action for signal */
35 T_QUIET
; T_ASSERT_POSIX_SUCCESS(sigaction(SIGCHLD
, &act
, NULL
), "Calling sigaction() failed for SIGCHLD");
37 /* Now fork a child that just exits */
39 T_QUIET
; T_ASSERT_NE_INT(pid
, -1, "fork() failed!");
46 /* Main program that did the fork */
47 /* We should process the signal, then exit */
48 while (!should_exit
) {