3 ms·
(Edit: Doh! Scooped by falsedan. His is shorter and probably more readable. :) In my defense, I tried it to make sure this works.) What I found via SO [0] wa
by gknoy 12y ago
(Edit: Doh! Scooped by falsedan. His is shorter and probably more readable. :) In my defense, I tried it to make sure this works.)
What I found via SO [0] was in the context of routing things to dev/null instead of stdout, but you appear to be able to route to whatever you need to:
;; Setup: A bash scropt printed 'wat' every second,
;; redirected to /dev/null
;; Attach to the process in question using gdb:
gknoy$ sudo gdb 15488
;; Use '1' as the open flag, for write-only
(gdb) p dup2(open("/tmp/wat.log",1),1)
$1 = 1
(gdb) detach
Detaching from program: /bin/bash, process 15488
(gdb) quit
gknoy$ cat /tmp/wat.log
wat
wat
wat
0: http://stackoverflow.com/questions/593724/redirect-stderr-stdout-of-a-process-after-its-been-started-using-command-lin http://stackoverflow.com/questions/593724/redirect-stderr-st...