On Fri, 1 Jul 2016 10:28:59 -0700 (PDT) ethanlewis...@gmail.com wrote: > I am starting to look into intercepting a running processes output. I > know how to do this manually by look at /proc/$PID/fd/1 or by using > gdb etc. I do not want to use os.exec and then join the child > processes output with the parent. I want to start Process A and > capture the output of A in Process B. Does anyone have any advice on > where to start or an opinion on why I should just use os.exec ? Any > advice/help would be great !
I'm afraid that this would be inherently kludgy. As C Banning hinted, the standard output (and input) streams of a process are _already_ connected to somewhere when a process starts up by an operating system. They can be opened to a file or something resembling a file -- such as an OS pipe or a socket. Hence what you want is "retargetting" an already opened and existing file descriptor of a foreign process, which is not something available in the "standard" set of system calls. If, for some reason, you still dearly need to do something like this, try looking at reptyr [1] which plays dirty unportable tricks with ptrace(). In any case it would be interesting to hear _why_ would you need that. 1. https://github.com/nelhage/reptyr -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.