]> git.saurik.com Git - apple/xnu.git/blobdiff - tests/sigchld_return.c
xnu-6153.11.26.tar.gz
[apple/xnu.git] / tests / sigchld_return.c
index 6a3cc6bcf8d46a7972dff156aa44bfe2fb76d918..01080d3b37b711cee65d34403ae8830d96809d46 100644 (file)
@@ -6,45 +6,46 @@
 
 #include <darwintest.h>
 
+T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
 
 static int exitcode = 0x6789BEEF;
 int should_exit = 0;
 
-void handler (int sig, siginfo_t *sip, __unused void *uconp)
+void
+handler(int sig, siginfo_t *sip, __unused void *uconp)
 {
-        /* Should handle the SIGCHLD signal */
-        T_ASSERT_EQ_INT(sig, SIGCHLD, "Captured signal returns 0x%x, expected SIGCHLD (0x%x).", sig, SIGCHLD);
-        T_QUIET; T_ASSERT_NOTNULL(sip, "siginfo_t returned NULL but should have returned data.");
-        T_ASSERT_EQ_INT(sip->si_code, CLD_EXITED, "si_code returns 0x%x, expected CLD_EXITED (0x%x).", sip->si_code, CLD_EXITED);
-        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);
-        should_exit = 1;
+       /* Should handle the SIGCHLD signal */
+       T_ASSERT_EQ_INT(sig, SIGCHLD, "Captured signal returns 0x%x, expected SIGCHLD (0x%x).", sig, SIGCHLD);
+       T_QUIET; T_ASSERT_NOTNULL(sip, "siginfo_t returned NULL but should have returned data.");
+       T_ASSERT_EQ_INT(sip->si_code, CLD_EXITED, "si_code returns 0x%x, expected CLD_EXITED (0x%x).", sip->si_code, CLD_EXITED);
+       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);
+       should_exit = 1;
 }
 
 
 T_DECL(sigchldreturn, "checks that a child process exited with an exitcode returns correctly to parent", T_META_CHECK_LEAKS(false))
 {
-        struct sigaction act;
-        int pid;
+       struct sigaction act;
+       int pid;
 
-        act.sa_sigaction = handler;
-        act.sa_flags = SA_SIGINFO;
+       act.sa_sigaction = handler;
+       act.sa_flags = SA_SIGINFO;
 
-        /* Set action for signal */
-        T_QUIET; T_ASSERT_POSIX_SUCCESS(sigaction (SIGCHLD, &act, NULL), "Calling sigaction() failed for SIGCHLD");
+       /* Set action for signal */
+       T_QUIET; T_ASSERT_POSIX_SUCCESS(sigaction(SIGCHLD, &act, NULL), "Calling sigaction() failed for SIGCHLD");
 
-        /* Now fork a child that just exits */
-        pid = fork();
-        T_QUIET; T_ASSERT_NE_INT(pid, -1, "fork() failed!");
+       /* Now fork a child that just exits */
+       pid = fork();
+       T_QUIET; T_ASSERT_NE_INT(pid, -1, "fork() failed!");
 
-        if (pid == 0) {
-                /* Child process! */
-                exit (exitcode);
-        }
+       if (pid == 0) {
+               /* Child process! */
+               exit(exitcode);
+       }
 
-        /* Main program that did the fork */
-        /* We should process the signal, then exit */
-        while (!should_exit) {
-                sleep(1);
-        }
+       /* Main program that did the fork */
+       /* We should process the signal, then exit */
+       while (!should_exit) {
+               sleep(1);
+       }
 }
-