销毁僵尸进程

//销毁僵尸进程2
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>

int main(int argc, char *argv[])
{
int status;
pid_t pid=fork();

if (pid==0)
{
sleep(15);
return 24;
}

else
{
while(!waitpid(-1,&status,WNOHANG))
{
sleep(3);
puts("sleep 3sec.");
}

if(WIFEXITED(status))
{
printf("child send %d\n",WEXITSTATUS(status));
}
return 0;
}
}

 

posted @ 2021-02-09 00:23  诗和远方*  阅读(36)  评论(0编辑  收藏  举报