Skip to content

Instantly share code, notes, and snippets.

@ryuichiueda
Created March 24, 2014 02:00
Show Gist options
  • Save ryuichiueda/9732941 to your computer and use it in GitHub Desktop.
Save ryuichiueda/9732941 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int main(){
int pid = fork(); //子の場合: 0, 親の場合: 子のPID
//子の処理
if (pid == 0){
puts("child");
exit(0);
}
//親の処理
while(1){
sleep(1);
puts("parent");
}
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment