relink - Echos outputs of a running program as if it was output of this command
relink PID
reredirect is a utility for taking an existing running program and attaching its outputs (standard output and error output) to files or another process.
Simple usage is:
reredirect -m FILE PID
It will redirect outputs of PID to FILE. It is also possible to redirect standard output and error output in different files:
reredirect -o FILE1 -e FILE2 PID
-m option is just a shortcut to -o FILE -e FILE
After launched, reredirect, give you command to restore state of PID. It will looks like:
reredirect -N -O 5 -E 3 5453
-O and -E act as -o and -e but with already opened file descriptors in PID. They only used to restore previous state of PID.
relink calls reredirect under the hood. It redirects outputs of a running program as if it was output of this command. On exit, this script automatically detach from PID , original output of PID is restored, and PID continue to run normaly.
Exemples:
relink $(pidof dhclient)
relink $(pidof dhclient) | grep usefull_line
-o FILE
-e FILE
-m FILE
-O FD
-E FD
-a
-N
-V
-h
-v
reredirect depends on the ptrace(2) system call to attach to the remote program. On Ubuntu Maverick and higher, this ability is disabled by default for security reasons. You can enable it temporarily by doing
as root, or permanently by editing the file /etc/sysctl.d/10-ptrace.conf, which also contains more information about this setting.
Bugs should be reported to the author (see below) or via the issue tracker on GitHub.
reredirect was mainly written by Jérôme Pouiller <jezz@sysmic.org>. You can contact hom for any questions or bug reports.
reredirect (and especially all ptrace layer) is based on reptyr programm. reptyr was written by Nelson Elhage <nelhage@nelhage.com>.