搜了搜比较有价值的是这一篇
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 process\n"
" - the child won't get here--you will only see this once\n" );
return 0;
}
Stack Overflow 上很少有人讨论这个话题,有大佬能发一下资料吗
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.