Ans*_*tel 4 process ps jobs background-process
我想知道为什么在否认停止的进程后,它仍然出现进程表
PING www.google.com (74.125.130.106) 56(84) bytes of data.
64 bytes from 74.125.130.106: icmp_seq=1 ttl=44 time=182 ms
64 bytes from 74.125.130.106: icmp_seq=2 ttl=44 time=209 ms
64 bytes from 74.125.130.106: icmp_seq=3 ttl=44 time=213 ms
64 bytes from 74.125.130.106: icmp_seq=4 ttl=44 time=122 ms
^Z
[1]+ Stopped ping www.google.com
anshul@anshul-Inspiron-N5010:~/Documents/workspace/shell$ jobs -l
[1]+ 10319 Stopped ping www.google.com
anshul@anshul-Inspiron-N5010:~/Documents/workspace/shell$ disown
bash: warning: deleting stopped job 1 with process group 10319
anshul@anshul-Inspiron-N5010:~/Documents/workspace/shell$ ps -ef | grep 10319
anshul 10319 9717 0 23:35 pts/25 00:00:00 ping www.google.com
Run Code Online (Sandbox Code Playgroud)
为什么还是显示10319进程,应该删除吧?
不,进程被停止,而不是被杀死。所以ps
还是会显示。
如果你运行ps ax
,你会看到它的状态是T
。在这种状态下,该进程在收到 SIGCONT 之前不会执行任何操作,然后它将继续运行(如果您fg
在终端中输入,您将看到该进程从它停止的点重新开始,因此在您的情况下,下一个icmp_seq
将是 5)。
编辑:我忘记了那disown
部分。由于您否认该过程,因此它不再出现在jobs
. 出于这个原因,你不能fg
。但是它仍然存在于ps
带有T
状态的输出中。因此,正如您所说,您仍然可以使用kill -sigcont <PID>
. 尽管如此,即使您发送了 SIGCONT,您也无法取消否认它,这意味着您将无法让它在终端的前台运行。