I know chances are extremely low, but is there a way to see what a nohup-ed process has been outputting recently?
I still have this process open but I've run it with redirecting all output to /dev/null.
So is there a way to recover such process back to console, or is it hopeless :(
Cheers
There is a way but it isn't straight forward, the trick is to use dup2 and depends on the fact that your program is linked against libc (which all c/c++ applications would be, but a java application wouldn't be for example)
run the following at the gdb prompt to redirect stdout to /tmp/newfile
$ print dup2(open("/tmp/newfile",0), 1)
run the following to redirect stderr to /tmp/newfile
$ print dup2(open("/tmp/newfile",0), 2)
What dup2 does is
duplicate a file descriptor This means that both stdout/stderr (1 and 2) and the new file descriptor returned from open can be used interchangeable which will cause all output going to stdout and stderr to go to the file you opened.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With