殭屍進程---子進程已經退出,但是父進程並沒有調用wait或waitpid獲取子進程的狀態信息,那麼子進程的進程描述符仍然保存在系統中
int main()
{
/*fork一個子進程*/
pid_t pid = fork();
if (pid > 0)/*父進程*/
{
printf("int parent process,sleep for one miniute...zZ...\n");
sleep(100);
printf("after sleep,and exit !\n");
}
else if (pid == 0)/*子進程*/
{
/*子進程退出,成爲一個殭屍進程*/
printf("in child process,and exit !\n");
exit(0);
}
return 0;
}