Most of the time running a gtk application from the command line it starts dumping debug information to the stdout even though I put them in background.


~$ gedit test.html # and ctrl+z to suspend
zsh: suspended  gedit .zshrc
~$ bg
[1]  + continued  gedit .zshrc
# do some editing
(gedit:6208): GtkSourceView-WARNING **: Could not find word to remove in buffer (whoosh), this should not happen!

(gedit:6208): GtkSourceView-WARNING **: Could not find word to remove in buffer (haystack), this should not happen!

I want to note that the error, or warning, changes according to what I'm doing at the moment. The GtkSourceView-WARNING shown here is one of the cases.

Anyway... Do you know if it's at all possible to avoid getting that information printed out?

  • Is it a bug that this info creeps out to the stdout even though I'm bging the process? – tutuca Mar 22 '12 at 13:52
  • I'm not acquainted with zsh, but I don't think so. Bash does the same thing. – zpletan Mar 26 '12 at 3:42
  • I didn't meant a bug in zsh... I mean a general bug in any application to print debug information in stdout .... Too much confusion in this question, I will vote for closing. – tutuca Mar 26 '12 at 16:08
  • 2
    Don't close it; if you think it's too confusing, edit it so it's not. Personally, I think it's a great question, and in the question body, I only see one question anyway. – zpletan Mar 26 '12 at 16:11
  • I would think piping it to grep with some arbitrary words after would work too. i.e. gedit | grep 'jkhcjbibijy1987189 jc1_12' – No Time May 15 '14 at 3:46

You can send those standard output and error messages to the null device, so that they don't show up in your terminal, e.g. gedit test.html >/dev/null 2>&1

  • 1
    tutuca did in the first comment to his question. – con-f-use Aug 29 '12 at 15:28

I don't know if this is exactly what you're looking for and if it'll help you, but:

Since you're saying that you want to run a GTK application in the background, you could do this:

nohup <applicationname> > /dev/null < /dev/null &

The nohup programm basically detaches the application passed to it from your terminal, allowing the terminal session to end, but with the application can still running.

You can close the terminal, or continue to use it (since all output is sent to /dev/null) without issues, because of the & command. A nice simple explanation for it can be seen here.

  • I know how to send apps to the background. What I want to avoid is the debug information getting printed. It happens with a lot of applications. – tutuca Mar 24 '12 at 1:25
  • Did you try the command? Because `> /dev/null < /dev/null does what you want (or at least, for me it does) – AeroCross Mar 24 '12 at 5:26
  • What's the point of < /dev/null? nohup already combines stderr and stdout so > /dev/null will silence all warnings. </dev/null reads from /dev/null and there's not point to that as far as I can tell. – terdon May 14 '14 at 16:57

Another way to do it would be to start the command as a background process and then detach it from the current shell. This will 'hide' all output in the sense that the current shell is no longer interested in the process. The syntax in bash is:

gedit test.html &
disown %1

I often use the output redirection mentioned in the other answer because it is very flexible. You can output to files, devices, connect outputs, etc. However this is useful for when you have no interest in the output, you just want to start a GUI application from a shell and then have no other interaction with it.

  • Why the parentheses? – enzotib Mar 22 '12 at 6:50
  • 1
    That's more or less equivalent to what the questioneer is doing now, so no, that won't hide the output. – geirha Mar 22 '12 at 7:28
  • I believe this is the same as issuing ctrl+z and bg, right? – tutuca Mar 22 '12 at 13:50
  • Yes it is the same but done without keyboard interaction so it can be used shell scripts and the like. Parentheses are for neatness. – Huckle Mar 22 '12 at 14:32
  • This will simply send to the background, it won't affect the messages printed in any way. – terdon May 14 '14 at 16:58

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.