先上代码:
僵尸状态&僵尸进程
#include <stdio.h>
#include <unistd.h>
int main()
{
printf("hello\n");
pid_t ret = fork();
if(ret < 0)
{
perror("fork");
return 0;
}
else if(ret == 0)
{
//child
while(1)
{
printf("i am child, pid=%d, ppid=%d\n", getpid(), getppid());
sleep(1);
}
}
else
{
//father
while(1)
{
printf("i am father, pid=%d, ppid=%d\n", getpid(), getppid());
sleep(1);
}
}
return 0