How can I read the standard output of an already-running process?
6 comments
·December 5, 2025ranger_danger
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 :)
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).
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