Chinaunix
标题:
为什么父进程不进行操作!?
[打印本页]
作者:
HunterForPig
时间:
2006-11-09 20:22
标题:
为什么父进程不进行操作!?
为什么父进程的printf没打印出来,只打出了child的信息??
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>
int main()
{
pid_t pid;
setbuf(stdout,NULL);
if((pid=fork()<0))
{
printf("fork error\n");
}
else if(pid >0)
{
printf("parent id:%d\n",getpid());
printf("parent'parent id:%d\n",getppid());
//exit(0);
}
else if(pid ==0)
{
sleep(3);
printf("========================\n");
}
exit(0);
}
郁闷,请指教
作者:
naker
时间:
2006-11-09 22:05
if((pid=fork()<0))
if((pid=fork())<0)
如果你说你是故意这么写的,看来谭浩强的书还得读呀。
作者:
HunterForPig
时间:
2006-11-10 08:40
thank u
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2