xref: /relibc/tests/waitpid.c (revision 269b8a1d3ebaa49d99677b1aef609037c16a9145)
1 #include <sys/wait.h>
2 #include <unistd.h>
3 #include <stdlib.h>
4 
5 #include "test_helpers.h"
6 
main(void)7 int main(void) {
8     pid_t pid = fork();
9     ERROR_IF(fork, pid, == -1);
10 
11     if (pid == 0) {
12         // child
13         sleep(1);
14         exit(EXIT_SUCCESS);
15     } else {
16         // parent
17         int stat_loc;
18         pid_t wid = waitpid(pid, &stat_loc, 0);
19         ERROR_IF(waitpid, wid, == -1);
20     }
21 }
22