1*94d3b452SApple OSS Distributions #include <signal.h> 2*94d3b452SApple OSS Distributions #include <stdio.h> 3*94d3b452SApple OSS Distributions #include <stdlib.h> 4*94d3b452SApple OSS Distributions #include <unistd.h> 5*94d3b452SApple OSS Distributions #include <errno.h> 6*94d3b452SApple OSS Distributions 7*94d3b452SApple OSS Distributions #include <darwintest.h> 8*94d3b452SApple OSS Distributions 9*94d3b452SApple OSS Distributions T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true)); 10*94d3b452SApple OSS Distributions 11*94d3b452SApple OSS Distributions T_DECL(sigcontreturn, "checks that a call to waitid() for a child that is stopped and then continued returns correctly") 12*94d3b452SApple OSS Distributions { 13*94d3b452SApple OSS Distributions pid_t pid; 14*94d3b452SApple OSS Distributions siginfo_t siginfo; 15*94d3b452SApple OSS Distributions pid = fork(); 16*94d3b452SApple OSS Distributions T_QUIET; T_ASSERT_NE_INT(pid, -1, "fork() failed!"); 17*94d3b452SApple OSS Distributions 18*94d3b452SApple OSS Distributions if (pid == 0) { 19*94d3b452SApple OSS Distributions while (1) { 20*94d3b452SApple OSS Distributions } 21*94d3b452SApple OSS Distributions } 22*94d3b452SApple OSS Distributions 23*94d3b452SApple OSS Distributions kill(pid, SIGSTOP); 24*94d3b452SApple OSS Distributions kill(pid, SIGCONT); 25*94d3b452SApple OSS Distributions sleep(1); 26*94d3b452SApple OSS Distributions 27*94d3b452SApple OSS Distributions T_QUIET; T_ASSERT_POSIX_SUCCESS(waitid(P_PID, pid, &siginfo, WCONTINUED), "Calling waitid() failed for pid %d", pid); 28*94d3b452SApple OSS Distributions 29*94d3b452SApple OSS Distributions 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 ); 30*94d3b452SApple OSS Distributions kill(pid, SIGKILL); 31*94d3b452SApple OSS Distributions } 32