微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

查看重定向到 dev/null 的进程的输出 - 撤消重定向

如何解决查看重定向到 dev/null 的进程的输出 - 撤消重定向

我已将几个进程推送到后台并将输出重定向/dev/null。我想撤消它,看看发生了什么,因为它在后台运行了很长时间。

有没有办法撤销 > /dev/null 重定向并将进程置于前台

解决方法

我认为您的问题最好发布在 unix 上。

在那里,您可以找到 How to change the output redirection of a running process?,这正是您的问题以更一般的形式提出的。

从答案以及其创建者在接受的答案中建议的第 3 方工具 (redirect)(主要是用 C 编写的),我推断没有仅使用 shell 的方法来完成您想要的.

不过这个问题是 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 […]

如果我正确解释引用,这可能是一种在后台启动进程而不会失去更改其文件描述符的能力的方法。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。