Skip to content

Instantly share code, notes, and snippets.

@hfm
Created December 20, 2013 04:50
Show Gist options
  • Select an option

  • Save hfm/8050523 to your computer and use it in GitHub Desktop.

Select an option

Save hfm/8050523 to your computer and use it in GitHub Desktop.
#include <unistd.h>
int main(void){
pid_t pid = fork();
if (pid > 0) {
printf("I am the parent of pid=%d!\n", pid);
} else if (!pid){
printf("I am the baby!\n");
} else if (pid == -1) {
perror("fork");
}
return 0;
}
@hfm

hfm commented Dec 20, 2013

Copy link
Copy Markdown
Author

$ ./a.out
I am the parent of pid=65025!
I am the baby!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment