Just how to reroute result of a running program to/ dev/null
I recognize that in order to subdue the result of a program I can reroute it to
/dev/null, as an example to hide all mistake and also advising messages from chromium I can start the program similar to this
chromium-browser 2> /dev/null &
Nonetheless, if I take place to forget the mistake messages and also type
(which is fairly aggravating when they show up in the center of a command) I do not recognize what to do with the exception of quiting the application and also beginning it once more effectively.
Can I in some way reroute mistake result without reactivating the application?
- affix to the procedure concerned making use of gdb, and also run :
- p dup2 (open ("/ dev/null", 0 ), 1 ) (for stdout redirection )
- p dup2 (open ("/ dev/null", 0 ), 2 ) (for stderr redirection )
- give up
I attempted it on the adhering to manuscript :
[version after first comment : ]
sleep 10 # so I can have the time to attach to the process if [ "$sonorfather" == "father" ] # avoid infinite recursion then sonorfather=son ./test & fi while true do echo "stdout $sonorfather" echo "stderr $sonorfather" >&2 sleep 1 done
I disabled the stderr result prior to the boy procedure was developed, below is the result :
stdout father stdout son stdout father stdout son [and so on...].
I wish this solution your inquiry : the boy procedure stderr was rerouted also.
You can additionally release the internet browser with nohup and afterwards close the incurable window with the adhering to :
nohup chromium-browser &
In this manner, the internet browser will certainly release and also detach from the console, that can after that be shut silently.
You can additionally arrangement a pen name for
chromium-browser to rather run
chromium-browser 2> /dev/null
e.g. if you are making use of celebration, modify/ home/username/. bashrc and also add line :
chromium-browser='chromium-browser 2> /dev/null'
or even better
chrome='chromium-browser 2> /dev/null'
and also conserve some keystrokes.