Tag: fork join

c fork,exec,getpid问题

我是c语言和Linux的新手。 我有一个与fork(),getpid()和exec()函数有关的问题。 我用fork()编写了ac程序,调用我程序的代码是“代码: #include #include #include #include void fun() { printf(“\n this is trial for child process”); } int main (int argc, char const *argv[]) { int i,status,pid,t; if(pid=fork()<0) { printf("\nfailed to create the process\n"); } if(pid=fork()==0) { printf("\n the child process is created"); fun(); exit(1); } while(wait(&status)!=pid); return 0; } 该计划的输出如下: 子进程已创建 这是儿童过程的试验 子进程已创建 […]