Linux 通过命令行恢复停止的进程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10700312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:25:49  来源:igfitidea点击:

Resume a stopped process through command line

linuxprocesssignalskill

提问by Ajish Alfred

I've executed the following C code in Linux CentOS to create a process.

我已经在 Linux CentOS 中执行了以下 C 代码来创建一个进程。

#include <stdio.h>
#include <unistd.h>

    int main ()
    {
          int i = 0;

          while ( 1 )
          {
                printf ( "\nhello %d\n", i ++ );
                sleep ( 2 );
          }
    }

I've compiled it to hello_count. When I do ./hello_count, The output is like this:

我已将其编译为hello_count. 当我这样做时./hello_count,输出是这样的:

hello 0
hello 1
hello 2
...

till I kill it. I've stopped the execution using the following command

直到我杀了它。我已使用以下命令停止执行

kill -s SIGSTOP 2956

When I do

当我做

ps -e

the process 2956 ./hello_countis still listed.

该过程2956 ./hello_count仍被列出。

Is there any command or any method to resume (not to restart) the process having process id 2956?

是否有任何命令或任何方法可以恢复(而不是重新启动)进程 ID 为 2956 的进程?

Also, when I stop the process, the command line shows:

此外,当我停止进程时,命令行显示:

[1]+ Stopped      ./hello_count

What does the [1]+in the above line mean?

什么是[1]+在上面的线是什么意思?

回答by tuxuday

  • To continue a stopped process, that is resume use kill -SIGCONT PID
  • Regd [1]+ that is bash way of handling jobs. For further information try help jobsfrom bash prompt.
  • 要继续停止的进程,即恢复使用kill -SIGCONT PID
  • Regd [1]+ 是 bash 处理作业的方式。有关更多信息,请尝试从 bash 提示符尝试帮助作业