23,116
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <unistd.h>
int main()
{
int ret_from_fork=111,mypid;
mypid=getpid();
printf("Before:my pid is %d\n",mypid);
ret_from_fork=fork();
sleep(1);
printf("After:my pid is %d,fork() said %d\n",getpid(),ret_from_fork);
return 0;
}
Before:my pid is 5495
After:my pid is 5495,fork() said 5496
After:my pid is 5496,fork() said 0