Fair enough. Simply reading from the file descriptor won&#x27;t work since some of the output will be redirected to the original process depending on who reads the next character first. The solution is to attach to the process using ptrace and then reditrect the stdout using dup. There is an example on how to do this with gdb on stackoverflow (<a href="http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;1323956&#x2F;how-to-redirect-output-of-an-already-running-process" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;1323956&#x2F;how-to-redirect-o...</a>) This would give a nice performance boost if you could implement this in your code.