Created
March 17, 2014 04:18
-
-
Save ryuichiueda/9593919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(){ | |
int pid = fork(); //子の場合: 0, 親の場合: 子のPID | |
//子の処理 | |
if (pid == 0){ | |
while(1){ | |
sleep(1); | |
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