In addition to @Dave's answer, there is an advanced method for redirecting input and output file descriptors of a running program using GDB.
FreeBSD script PID 4711:
> gdb /bin/sh 4711
...
Attaching to program: /bin/sh, process 4711
...
(gdb) p close(1)
$1 = 0
(gdb) p creat("/tmp/testout.txt",0644)
$2 = 1
(gdb) p close(2)
$3 = 0
(gdb) p dup2(1,2)
$4 = 2
EDIT - : 1, , 1. 2 1 2.
stdout stderr . stdin, p close(0), PIPE smth.
disown , , , SIGHUP.
. / , disown -a, .