擅长:python、mysql、java
<p>如其他答案所述,这是由您的外壳打印的。shell监视它派生的每个子进程的状态。其中一个子进程是python程序。当它停止时,shell会得到通知(使用<code>SIGCHLD</code>),获取停止的子进程的终止状态,并打印该消息,让您知道其中一个正在运行的作业现在被挂起。在</p>
<p>我不知道是否可以将bash配置为停止打印作业状态更改,但是您可以做一些其他的事情:在<code>prog.py</code>中,只需<code>fork()</code>并在父级中退出,让子级保持活动状态。这会导致<code>prog.py</code>成为<code>init</code>的子元素(而不是{<cd6>}的子元素),因此{<cd6>}将不再关心它。在</p>
<p>我不知道Python,但下面是一个用C编写的示例:</p>
<pre><code>#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int main(void) {
pid_t f;
if ((f = fork()) < 0) {
perror("Unable to fork");
exit(EXIT_FAILURE);
}
if (f == 0) {
/* Child takes over */
while (1); /* Just place your code here */
}
return 0;
}
</code></pre>
<p>我相信您可以在Python中执行类似的操作。在</p>