发新话题
打印

【求助】fork创建子进程问题

【求助】fork创建子进程问题

我在看linux0.11的源代码,在main()中init()函数中有这样的代码
1.(!(pid=fork())) {
  2.close(0);
3. if (open("/etc/rc",O_RDONLY,0))
  4. _exit(1);
5. execve("/bin/sh",argv_rc,envp_rc);
  6._exit(2);
7. }
8.if (pid>0)
  9.while (pid != wait(&i))
   /* nothing */
第一行和第八行的pid值怎么会不一样
请高手指点一下

TOP

pid好象叫“进程ID”(线程ID?)

我菜鸟,帮不了你。感觉象是说如果找到pid,而且pid状态不是wait(好象叫休眠),就....
Linux新新手:D

TOP

问题已经解决

TOP

simple:fork system call return different value to father process(non zero) and son process(zero)!
clear??

TOP

发新话题