C 紫禁城 Fork(), execvp 是个啥?好难找到资料啊
搜了搜比较有价值的是这一篇
https://ece.uwaterloo.ca/~dwharder/icsrts/Tutorials/fork_exec/
#include <stdio.h> /* This program forks and and the prints whether the process is * - the child (the return value of fork() is 0), or * - the parent (the return value of fork() is not zero) * * When this was run 100 times on the computer the author is * on, only twice did the parent process execute before the * child process executed. * * Note, if you juxtapose two strings, the compiler automatically * concatenates the two, e.g., "Hello " "world!" */ int main( void ) { char *argv[3] = {"Command-line", ".", NULL}; int pid = fork(); if ( pid == 0 ) { execvp( "find", argv ); } /* Put the parent to sleep for 2 seconds--let the child finished executing */ wait( 2 ); printf( "Finished executing the parent processn" " - the child won't get here--you will only see this oncen" ); return 0; }
Stack Overflow 上很少有人讨论这个话题,有大佬能发一下资料吗