Skip to content
Snippets Groups Projects
Forked from redox-os / relibc
1239 commits behind the upstream repository.
waitpid.c 395 B
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>

#include "test_helpers.h"

int main(void) {
    pid_t pid = fork();
    ERROR_IF(fork, pid, == -1);

    if (pid == 0) {
        // child
        sleep(1);
        exit(EXIT_SUCCESS);
    } else {
        // parent
        int stat_loc;
        pid_t wid = waitpid(pid, &stat_loc, 0);
        ERROR_IF(waitpid, wid, == -1);
    }
}