Created
November 24, 2018 15:37
-
-
Save shihyu/10f7021b4a0f277b1cf9d045a8d41e86 to your computer and use it in GitHub Desktop.
Revisions
-
shihyu created this gist
Nov 24, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #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; }