日期:2014-05-16  浏览次数:20725 次

进程的菜鸟问题
本帖最后由 dwightsun 于 2014-04-15 19:00:40 编辑

#include<errno.h>
#include<error.h>
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<stdlib.h>
#include<string.h>


char command[256];


int main()
{
pid_t pc,pr,status=0;
pc = fork();
if(pc < 0)
{
printf("error occurred when creating child process!\n");
}
else if(pc == 0)
{
printf("child process with pid of %d\n",getpid());

exit(5);
}
else
{
sleep(1);
pr = wait(&status);
printf("parent catched a child process with pid of %d %d",pr,status);
}
exit(0);
    return 0;
}



这里为什么status变量到输出值是1280?
按照例子应该是5啊?
------解决方案--------------------
http://www.2cto.com/os/201107/98258.html
http://hi.baidu.com/baowup/item/a6f863ea68bb6c0c560f1d1c