进程学习-僵尸进程

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
main()
{
pid_t pid; pid = fork();
if(pid < 0)
printf("error occurred!\n");
else if(pid == 0) {
printf("Hi father! I'm a ZOMBIE\n"); exit(0); //no one waits for this process.
}
else {
sleep(10); wait(NULL); //the zombie process will be reaped now.
}
}

posted @ 2017-05-22 14:11  qlky  阅读(157)  评论(0编辑  收藏  举报