EXECVP start a new program in the program:
To create a new process with fork:
Forkdemo2 Code:
When testing the fork, refer to the Linux authoritative guide reading notes (3) using patches:
[Email protected] programming]#diff-C forkdemo2.c forkdemo2_new.c > Forkdemo2.Patch[email protected] programming]#Patch< Forkdemo2.PatchPatchingfileForkdemo2.c[[email protected] programming]#ls-Lrttotal7-rwxrwxrwx1Root root4953Sep6 One: toForkdemo2-rwxrwxrwx1Root root4957Sep6 One: -forkdemo2_new-rwxrwxrwx1Root root119Sep6 One: -forkdemo2_new.c-rwxrwxrwx1Root root263Sep6 One: -Forkdemo2.Patch-rwxrwxrwx1Root root119Sep6 One: - forkdemo2.c[[email protected] programming]#
This FORKDEMO2 output PID number is also very interesting, preferably from the bottom of the bargain.
How to determine whether a parent or child process: The return value of fork () in the parent process is the PID of the child process, which is 0 in the child process.
Unix/linux Programming Practice Tutorials