进程如何在Linux上拦截另一个进程的stdout和stderr? [英] How can a process intercept stdout and stderr of another process on Linux?

查看:264
本文介绍了进程如何在Linux上拦截另一个进程的stdout和stderr?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些脚本应该已经停止运行,但是永远挂在后面.有什么办法可以使我以一种可读的方式弄清楚它们正在向STDOUT和STDERR写入什么内容?

I have some scripts that ought to have stopped running but hang around forever. Is there some way I can figure out what they're writing to STDOUT and STDERR in a readable way?

例如,我尝试这样做:

$ tail -f /proc/(pid)/fd/1

但这并不能真正起作用.无论如何,这是一个远景.

but that doesn't really work. It was a long shot anyway.

还有其他想法吗?

strace本身很冗长,因此看不清.

strace on its own is quite verbose and unreadable for seeing this.

注意:我对它们的输出感兴趣,而不对其他任何东西感兴趣.我有能力自己弄清其他事情;这个问题仅集中在启动运行后的进程 的stdout和stderr上.

Note: I am only interested in their output, not in anything else. I'm capable of figuring out the other things on my own; this question is only focused on getting access to stdout and stderr of the running process after starting it.

推荐答案

我不确定它是否适合您,但我读了一段时间描述了

I'm not sure if it will work for you, but I read a page a while back describing a method that uses gdb

这篇关于进程如何在Linux上拦截另一个进程的stdout和stderr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆