Created
November 24, 2018 15:37
-
-
Save shihyu/10f7021b4a0f277b1cf9d045a8d41e86 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 <sys/types.h> | |
#include <unistd.h> | |
int fork_1() | |
{ | |
int childpid; | |
int i; | |
if (fork() == 0) { | |
//child process | |
for (i = 1; i <= 20; i++) { | |
printf("This is child process\n"); | |
} | |
} else { | |
//parent process | |
for (i = 1; i <= 2; i++) { | |
printf("This is parent process\n"); | |
} | |
} | |
printf("step2 after fork() !! pid=%d\n\n", getpid()); | |
} | |
int main() | |
{ | |
fork_1(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment