【问题标题】:what is the result of Z+ in ps command?ps 命令中 Z+ 的结果是什么?
【发布时间】:2011-10-08 12:30:08
【问题描述】:

我用这段代码创建了一个僵尸进程:

pid_t child; cout<<getpid(); child=fork(); if (child>0) sleep(60); else exit(0);

我正在使用这个命令:

ps -e -o pid,ppid,stat,command

没关系,但我希望在我的进程(stat)前面看到 Z,但它是 Z+,这是什么意思?

【问题讨论】:

    标签: unix process posix


    【解决方案1】:

    来自 ps 的手册页,更具体地说是进程状态代码:

    Z    defunct ("zombie") process, terminated but not reaped by its parent.
    +    is in the foreground process group.
    

    当 shell 执行您的代码时,它会将您的程序更改为一个单独的前台进程组。您的代码的每个子进程都与原始程序位于同一个前台进程组中,因此即使父进程退出,子进程仍位于前台进程组中,这就是您看到 + 的原因。

    【讨论】:

      猜你喜欢
      • 2011-10-30
      • 2015-05-24
      • 1970-01-01
      • 2012-05-22
      • 1970-01-01
      • 2014-02-04
      • 2012-05-29
      • 2020-03-31
      • 1970-01-01
      相关资源
      最近更新 更多