Existe um hack inteligente citado aqui que usa o GDB para anexar ao processo, e um utilitário chamado dupx finaliza essa funcionalidade.
Dupx is a simple utility to remap files of an already running program. Shells like Bash allow easy input/output/error redirection at the time the program is started using
>, < -like syntax, e.g.:echo 'redirect this text' > /tmp/stdoutwill redirect output ofechoto/tmp/stdout.Standard shells however do not provide the capability of remapping (redirecting) of output (or input, or error) for an already started process. Dupx tries to address this problem by using
dup(2)system call from insidegdb(1). Dupx is currently implemented as a simple shell wrapper around agdbscript.