【发布时间】:2021-04-14 19:07:20
【问题描述】:
我已将几个进程推送到后台并将输出重定向到/dev/null。我想撤消它,看看它在后台很长时间后发生了什么。
有没有办法撤消> /dev/null 重定向并将进程带到前台?
【问题讨论】:
标签: linux shell io-redirection
我已将几个进程推送到后台并将输出重定向到/dev/null。我想撤消它,看看它在后台很长时间后发生了什么。
有没有办法撤消> /dev/null 重定向并将进程带到前台?
【问题讨论】:
标签: linux shell io-redirection
我认为你的问题最好发布在unix。
在那里,您可以找到How to change the output redirection of a running process?,这正是您的问题以更一般的形式提出的。
从答案,以及从其创建者接受的答案中建议的第 3 方工具 (redirect),我推断没有 shell-only 方法可以完成你想要的。
不过,这个问题是 2012 年提出的,所以您可能想问一个新问题,看看在此期间是否发生了一些变化。
最后但同样重要的是,在man bash 中进行一些搜索,我找到了Coprocesses 部分,内容为
[…] A coprocess is executed asynchronously in a subshell, as if the command had been terminated with the & control operator, with a two-way pipe established between the executing shell and the coprocess. […] The standard output of command is connected via a pipe to a file descriptor in the executing shell, and that file descriptor is assigned to NAME[0]. The standard input […]
如果我正确解释了引号,这可能是一种在后台启动进程而不会失去更改其文件描述符的能力的方法。
【讨论】: