
Redirect a running process output to a file and log out - zaius
https://gist.github.com/782263
======
paulitex
Explained with comments: <https://gist.github.com/782312> (edit: made
clearer).

~~~
zaius
Nice. Thanks for that. The only addendum I would make is that the second
parameter to open specifies to open the file as writable. Usually the constant
is O_WRONLY, but it wasn't working for me in GDB.

------
sliverstorm
Wow, I get that the gdb stuff is the real clever trickery, but 'disown' is the
most valuable thing I got from that. I knew about nohup, but I didn't know
about disown.

~~~
zaius
Disown is actually implemented by bash (or your shell of choice). From my
understanding, it just stops the HUP propagating down to that child. There
might be a more shell-agnostic way to assign the parent process id too.

------
julian37
Someone has rolled this into a script:

<http://www.isi.edu/~yuri/dupx/>

~~~
yycom
This always annoys me:

 _Dupx is currently implemented as a simple shell script_

So why can't I just download this "simple shell script"?

~~~
lysium
Extract it from the provided tarball. Almost as easy, but with no man page.

~~~
yycom
duh

------
fendrak
Alternatively, if you know you're going to want to do this beforehand, check
out the 'nohup' command. It does basically the same thing with any command
it's given.

<http://en.wikipedia.org/wiki/Nohup>

------
ryandotsmith
Is this better than running the program in something like screen or tmux?

~~~
angusgr
I get the impression that this is for when you've forgotten to set up
something like screen beforehand.

------
gbrindisi
Am I a bad person for using nohup and stderr/stdout redirect?

Anyway this is a really nice creative alternative.

~~~
lysium
Actually, it's not meant as an alternative, but when you forgot to use nohup
or stderr/stdout redirect, ie. redirect output from an already running
process.

