If you have a running process (es. a daemon) and you want modify his stdin, stdout or stderr, this is the way you can do it:
$ gdb -p 4227
(gdb) p close(0)
$1 = 0
(gdb) p close(1)
$2 = 0
(gdb) p close(2)
$3 = 0
(gdb) p creat(“/tmp/test_input”, 0644)
$4 = 0
(gdb) p creat(“/tmp/test_output”, 0644)
$5 = 1
(gdb) p creat(“/tmp/test_error”, 0644)
$6 = 2
(gdb) quit
$ ls -l /proc/4227/fd
totale 0
lrwx—— 1 francesco users 64 23 apr 09:50 0 -> /tmp/test_input
lrwx—— 1 francesco users 64 23 apr 09:50 1 -> /tmp/test_output
lrwx—— 1 francesco users 64 23 apr 09:50 2 -> /tmp/test_error