Skip to content

Instantly share code, notes, and snippets.

@bitjockey42
Created May 14, 2016 22:02
Show Gist options
  • Save bitjockey42/8731617c1a62e680a63664e4f140263c to your computer and use it in GitHub Desktop.
Save bitjockey42/8731617c1a62e680a63664e4f140263c to your computer and use it in GitHub Desktop.
// System
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pwd.h>
#include <assert.h>
#include <errno.h>
#include <uuid/uuid.h>
int main()
{
pid_t child1, child2;
if ((child1 = fork()) == 0) {
if ((child2 = fork()) == 0) {
printf("This is the second child!\n");
sleep(2);
} else {
wait(NULL);
printf("This should be the first child.\n");
}
} else {
wait(NULL);
printf("This is the parent\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment