Skip to content(if available)orjump to list(if available)

How can I read the standard output of an already-running process?

ranger_danger

I know this article is for Windows, but if you're wondering if there's a way to do this on Linux, there is:

https://strace.io/

https://github.com/nelhage/reptyr

https://github.com/crigler/dtach

https://github.com/jerome-pouiller/reredirect

https://github.com/pasky/retty

jmclnx

Thanks, links saved.

Then there is this method, but I guess that article refers to no redirection output.

If in background or via cron, I always redirect. But this is for UN*X type systems with a tail that supports '-f'

$ prog > /tmp/log.txt 2>&1 &

Then

$ tail -f /tmp/log.txt

Just so happens, I actually used this the other day for a long running process on OpenBSD :)

hmng

Isn't that what tee is for? Like

$ prog | tee /tmp/log.txt

gosub100

That's if you start the process with advance knowledge that you'll want to tail the output and log it. Not if you want to view the output of an existing process

amelius

Can't you attach to it from GDB?

gary_0

Or you could patch the executable on disk or in memory, or probably some other hacks I'm not thinking of. I think he means that there's no Windows API or "proper" way to do it, not that it's literally impossible (it's running on a general-purpose computer, after all).