#include
#include
int main()
{
int pid;
pid = fork();
if (pid == 0) // child process
{
printf("child process PID=%d, parent process PID=%d\n", getpid(), getppid());
}
else if (pid > 0) // parent process
{
printf("parent process PID=%d, pparent process PID=%d\n", getpid(), getppid());
}
return 0;
}
results: child process PID=2215, parent process PID=1
parent process PID=2214, pparent process PID=2011
阅读(536) | 评论(0) | 转发(0) |