#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
int main()
{
pid_t pid;
pid = fork();
if(pid < 0)
printf("error occurred!\n");
else
{
if(pid == 0)/*child 进程*/
{
exit(0);
}
else
{
sleep(30);/*父进程pause*/
}
}
wait(NULL);/*收集僵尸进程*/
return 0;
}
ps -aux
lgy 3016 0.0 0.0 0 0 pts/0 Z+ 19:27 0:00 [a.o] <defunct>