How to move a process into the background and also silence its output

job-control

Say I start a process in the terminal and it sends output to standard error while it runs. I want to move the process into the background and also silence it at the same time.

Is there a way to do this without stopping the process and starting it again using & and > /dev/null 2>&1 ? I'm wondering if there is some command that performs bg and can change the output descriptors of the target process too.

Best Answer

Too late. After a process is started, shell has no more control on process file descriptors so you can not silence it by a shell command.

You can only try to kill a SIGHUP to the process. If your process handles it correctly, It should detach from controlling tty. Unluckily, many software do not handle it correctly and simply die.

Related Question