6、回调函数 pid=fork(); if (pid < 0) printf("error in fork!"); else if (pid == 0) printf("i am the child process, my process id is %d/n",getpid()); else { printf("
7、i am the parent process, my process id is %d/n",getpid()); sleep(2); wait(); } } iamthechildprocess,myprocessidis15806theexitpid:15806iamtheparentprocess,myprocessidis15805theexitpid:15805这是gcc测试下的运行结果。 关于fork函数