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