reredirect

Section: User Commands (1)
Updated: 26 Aug 2014
Index Return to Main Contents
 

NAME

reredirect - Tool to dynamically redirect outputs of a running process

relink - Echos outputs of a running program as if it was output of this command

 

SYNOPSIS

reredirect [-m FILE |-o FILE |-e FILE |-O FD |-E FD ] [-a] [-N] PID

relink PID

 

DESCRIPTION

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

 

OPTIONS

-o FILE

File to redirect stdout

-e FILE

File to redirect stderr

-m FILE

Same than -o FILE -e FILE

-O FD

Redirect stdout to this file descriptor. Mainly used to restore process outputs

-E FD

Redirect stderr to this file descriptor. Mainly used to restore process outputs

-a

Append to FILE files (see -o and -e options) instead of overwriting them.

-N

Do not save previous stream

-V

Print the version of reredirect and exit.

-h

Print a usage message and exit.

-v

Print verbose debug output while running.

 

NOTES

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


 # echo 0 > /proc/sys/kernel/yama/ptrace_scope

as root, or permanently by editing the file /etc/sysctl.d/10-ptrace.conf, which also contains more information about this setting.

 

BUGS

Bugs should be reported to the author (see below) or via the issue tracker on GitHub.

 

SEE ALSO

dupx(1)

 

AUTHORS

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>.

 

HOMEPAGE


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
NOTES
BUGS
SEE ALSO
AUTHORS
HOMEPAGE

This document was created by