From this page.
This is pretty cool. Say you've got a long-running process that you really should have put in screen or nohup, but were too short-sighted. I find myself in this position a lot. Suppose also that you compound your lack of wisdom by accidentally deleting the file that it was writing to, or some other how fuck up the streams, but it's still printing to stdout.
ls -l /proc/$p$/fd. 1 is probably the stdout.gdb -p $p$p close(1). Should print sth like $1 = 0.p creat(”/tmp/iamidiot”, “0600”). Should print sth like $2 = 1.q.That was fantastic.
Quick note: If creat didn't return 1, you can rename what it did return using p dup2(3, 1), which should return sth like $2 = 1. See this page on stackoverflow for details.