Skip to main content
1 of 4

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid>    
... 
(gdb) call open("/dev/null",O_WRONLY)
$1 = 3
(gdb) call dup2($1,1)
$2 = 0
(gdb) call close($1)
$3 = 0
(gdb) detach

here according to header fcntl.h O_WRONLY has value 1 . and if we want to find a file descriptor already opened , we can .

$ cd /proc/<pid>/fd
$ for i in * ; do
          if [[ `readlink $i` == "/dev/null" ]]
                  fd=$i ; break
          fi
  done