]> git.saurik.com Git - apple/xnu.git/blame - tools/tests/darwintests/sigcont_return.c
xnu-4570.1.46.tar.gz
[apple/xnu.git] / tools / tests / darwintests / sigcont_return.c
CommitLineData
5ba3f43e
A
1#include <signal.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <unistd.h>
5#include <errno.h>
6
7#include <darwintest.h>
8
9T_DECL(sigcontreturn, "checks that a call to waitid() for a child that is stopped and then continued returns correctly")
10{
11 pid_t pid;
12 siginfo_t siginfo;
13 pid = fork();
14 T_QUIET; T_ASSERT_NE_INT(pid, -1, "fork() failed!");
15
16 if (pid == 0) {
17 while(1){}
18 }
19
20 kill(pid, SIGSTOP);
21 kill(pid, SIGCONT);
22 sleep(1);
23
24 T_QUIET; T_ASSERT_POSIX_SUCCESS(waitid(P_PID, pid, &siginfo, WCONTINUED), "Calling waitid() failed for pid %d", pid);
25
26 T_ASSERT_EQ_INT(siginfo.si_status, SIGCONT, "A call to waitid() for stopped and continued child returns 0x%x, expected SIGCONT (0x%x)", siginfo.si_status, SIGCONT );
27 kill(pid, SIGKILL);
28}