Skip to content

Instantly share code, notes, and snippets.

@danrl
Created May 23, 2018 19:43
Show Gist options
  • Save danrl/3e6984eb376ee4c298843344c6119d95 to your computer and use it in GitHub Desktop.
Save danrl/3e6984eb376ee4c298843344c6119d95 to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int argc, char *argv[]) {
pid_t pid = fork();
if (pid == 0) {
// child exits immediately
return 0;
}
// parent sleeping, not eager to call wait()
sleep(10);
// yeah, maybe now...
wait(NULL);
// exit ok
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment