Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix 僵尸进程是如何表现自己的?_Unix_Operating System - Fatal编程技术网

Unix 僵尸进程是如何表现自己的?

Unix 僵尸进程是如何表现自己的?,unix,operating-system,Unix,Operating System,kill-s SIGCHLD 上面是杀死任何僵尸进程的代码,但我的问题是: 一个僵尸进程是否有任何方式来表现自己 steenhulthin是正确的,但在它被移动之前,还是有人在这里回答它为好。在子进程终止和父进程调用其中一个wait()函数以获取其退出状态之间,存在一个僵尸进程 一个简单的例子: /* Simple example that creates a zombie process. */ #include <stdio.h> #include <unistd.h&g

kill-s SIGCHLD

上面是杀死任何僵尸进程的代码,但我的问题是:

一个僵尸进程是否有任何方式来表现自己

steenhulthin是正确的,但在它被移动之前,还是有人在这里回答它为好。在子进程终止和父进程调用其中一个
wait()
函数以获取其退出状态之间,存在一个僵尸进程

一个简单的例子:

/* Simple example that creates a zombie process. */

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

int main(void)
{
    pid_t cpid;
    char s[4];
    int status;

    cpid = fork();

    if (cpid == -1) {
        puts("Whoops, no child process, bye.");
        return 1;
    }

    if (cpid == 0) {
        puts("Child process says 'goodbye cruel world.'");
        return 0;
    }

    puts("Parent process now cruelly lets its child exist as\n"
         "a zombie until the user presses enter.\n"
         "Run 'ps aux | grep mkzombie' in another window to\n"
         "see the zombie.");

    fgets(s, sizeof(s), stdin);
    wait(&status);
    return 0;
}
/*创建僵尸进程的简单示例*/
#包括
#包括
#包括
#包括
内部主(空)
{
pid_t cpid;
chars[4];
智力状态;
cpid=fork();
如果(cpid==-1){
puts(“哎呀,没有子进程,再见”);
返回1;
}
如果(cpid==0){
puts(“儿童进程说‘再见残酷的世界’”);
返回0;
}
puts(“父进程现在残酷地允许其子进程作为\n存在”
“直到用户按enter键时,才会激活僵尸。\n”
“在另一个窗口中运行'ps aux | grep mkzombie'以\n”
“看僵尸。”);
fgets(s、sizeof(s)、stdin);
等待(&状态);
返回0;
}

这是个好问题,但我认为它更适合于+1,或者可能是+1,因为“残酷地让它的孩子存在……”,这是一个好答案。