日期:2014-05-16 浏览次数:20840 次
}
进程链的例子:
/* 由父进程派生子进程,子进程再派生子进程 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
pid_t pid;
int i;
for(i=0;i<10;i++)
if ((pid = fork()) <= 0)
break;
printf("=============================================\n");
printf("My pid is %ld\n",getpid());
printf("My parent pid is %ld\n",getppid());
return 0;
}