I know that in order to suppress the output of a program I can redirect it to /dev/null, for example to hide all error and warning messages from chromium I can start the program like this

chromium-browser 2> /dev/null &

However, if I happen to forget about the error messages and type

chromium-browser &

(which is quite annoying when they appear in the middle of a command) I don't know what to do except for stopping the application and starting it again properly.

Can I somehow redirect error output without restarting the application?


You can also launch the browser with nohup and then close the terminal window with the following:

nohup chromium-browser &

This way, the browser will launch and detach from the console, that can then be closed quietly.

  • 2
    that is acceptable, except for the fact that I'll have to remember to type nohup – phunehehe Sep 3 '10 at 14:07
  • 5
    @phu On zsh at least you can put setopt nohup in your .zshrc and it will nohup everything you run; I'm not sure about other shells – Michael Mrozek Sep 3 '10 at 14:27
  • yes, great, I like it this way! – phunehehe Sep 3 '10 at 14:41
  • 3
    Or you can create an alias... alias chromium = nohup chromium – Pablo Olmos de Aguilera C. Oct 17 '12 at 21:04

This was answered here : here by vladr. The answer is (quoting) :

  • attach to the process in question using gdb, and run:
  • p dup2(open("/dev/null", 0), 1) (for stdout redirection)
  • p dup2(open("/dev/null", 0), 2) (for stderr redirection)
  • detach
  • quit

I tried it on the following script :

[edition after first comment :]

sleep 10 # so I can have the time to attach to the process
if [ "$sonorfather" == "father" ] # avoid infinite recursion 
   sonorfather=son ./test & 

while true 
   echo "stdout $sonorfather" 
   echo "stderr $sonorfather" >&2 
   sleep 1 

I disabled the stderr output before the son process was created, here is the output :

stdout father 
stdout son 
stdout father 
stdout son 
[and so on...]. 

I hope this answer your question : the son process stderr was redirected too.

  • 3
    that was very good, but then I may have problems with chromium, as it spawns a new process for each browser tab, anyway to resolve? – phunehehe Sep 3 '10 at 9:02
  • Edited my post to answer you. – Mike Perdide Sep 3 '10 at 9:49
  • Look like I'll need to redirect the output before the child processes are created? Thanks for the knowledge, but regarding the complexity I'd just go with nohup :) – phunehehe Sep 4 '10 at 10:23
  • Technically, this leaks duplicate file descriptors for /dev/null, but in practice that does not significantly affect anything. – Kevin Aug 20 '15 at 17:40

You could also setup an alias for chromium-browser to instead run chromium-browser 2> /dev/null

e.g. if you are using bash, edit /home/username/.bashrc and add line:

chromium-browser='chromium-browser 2> /dev/null'

or better yet

chrome='chromium-browser 2> /dev/null'

and save some keystrokes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.