加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

unix – 僵尸进程如何表现自己?

发布时间:2020-12-15 21:51:02 所属栏目:安全 来源:网络整理
导读:kill -s SIGCHLD 以上是杀死任何僵尸进程的代码,但我的问题是: Zombie进程有什么方法可以表现出来吗? 解决方法 steenhulthin是正确的,但直到它被移动,有人可能会在这里回答它.子进程终止的时间与父进程调用wait()函数之一以获得其退出状态的时间之间存在僵
kill -s SIGCHLD
以上是杀死任何僵尸进程的代码,但我的问题是:
Zombie进程有什么方法可以表现出来吗?

解决方法

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 asn"
         "a zombie until the user presses enter.n"
         "Run 'ps aux | grep mkzombie' in another window ton"
         "see the zombie.");

    fgets(s,sizeof(s),stdin);
    wait(&status);
    return 0;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读