【发布时间】:2012-05-30 16:28:38
【问题描述】:
我在 Linux CentOS 中执行了以下 C 代码来创建进程。
#include <stdio.h>
#include <unistd.h>
int main ()
{
int i = 0;
while ( 1 )
{
printf ( "\nhello %d\n", i ++ );
sleep ( 2 );
}
}
我已将其编译为 hello_count。当我在终端窗口中执行./hello_count 时,输出是这样的:
hello 0
hello 1
hello 2
...
当我在另一个终端窗口输入命令时
ps -e
那里列出了进程 2956 ./hello_count。在同一个窗口中,我使用以下命令停止了该过程:
kill -s SIGSTOP 2956
当我再次输入以下命令时,
ps -e
进程 2956 ./hello_count 仍在列出。
然后我输入了以下命令以在同一窗口中恢复该过程。
kill -s SIGCONT 2956
但是,进程在之前执行并提供输出的窗口中恢复。
是否有任何命令或方法可以在不同的终端窗口中恢复(而不是重新启动)pid 为 2956 的进程?
我的意思是,我需要这样的输出,
hello 8
hello 9
...
在我停止进程之前获得上述输出的窗口之外的窗口中。
【问题讨论】:
-
man screen 就是你要阅读的内容。
标签: linux process terminal command