In the shell you can do redirection, >
<
, etc., but how about AFTER a program is started?
Here's how I came to ask this question, a program running in the background of my terminal keeps outputting annoying text. It's an important process so I have to open another shell to avoid the text. I'd like to be able to >/dev/null
or some other redirection so I can keep working in the same shell.
Redirect output from a running process to another terminal, file or screen:
Inside gdb:
Detach a running process from bash terminal and keep it alive:
Explanation:
20818 - just an example of running process pid
p - print result of gdb command
close(1) - close standard output
/dev/pts/4 - terminal to write to
close(2) - close error output
/tmp/myerrlog - file to write to
q - quit gdb
bg %1 - run stoped job 1 on background
disown %1 - detach job 1 from terminal