When I run a program from the console, e.g.

me@box:~$ firefox

I expect the console to log error messages (I think this is std out or std err?) and other items from the program, firefox in this case.

But today I notice that bash just opens the program and goes to a new prompt, e.g.

me@box:~$ firefox

How do I launch a program from bash such that error messages will be written to the console?

Why is it that some programs operate this way by default and others (firefox) do not?

  • I think this may be the result of a ghost process or something. I had a segfault from compiz an hour before and haven't logged out, just restarted compiz. – Dan Dman Jun 6 '12 at 2:47

You are correct that this is the result of an already-running process, but unless there is a bug in Firefox, it should not be the result of a zombie process.

When you start Firefox, the very new instance of Firefox checks to see if Firefox is already running. If Firefox is already running, then instead of continuing as a separate instance, the very new instance communicates with the already-running instance, and makes it start a new window, or a new tab. If a URL was specified as a command-line argument to the very new instance of Firefox, it communicates that URL to the already-running instance, so a window or tab is started in the already-running instance, opening a page with the URL you specified. Once this very new second instance has told the original already-running instance what to do, this very new instance terminates, leaving just one instance.

You can verify this behavior by starting the first Firefox instance with a URL as a command-line argument (e.g., firefox http://askubuntu.com/q/147059/22949), and then making a new window/tab by running the firefox command again with a different URL (e.g., firefox http://www.google.com). When you examine running processes with ps x, you'll see that the only running firefox instance has the first URL as its command-line argument (because the second command is no longer running).

It's often said that you can't run more than one instance of Firefox at a time. It's more accurate to say that you can't run more than one instance of Firefox at a time, for more than a fraction of a second.

Because of this behavior, when you invoke a second instance of Firefox from within a shell, that instance terminates almost immediately, giving you another shell prompt like any program that has finished executing.

Another commonly used program in Ubuntu that does this is Nautilus (the file browser).

It is possible for Firefox to be running but have no windows shown, though typically that should only be able to happen for a short time after quitting all Firefox windows, unless there is a bug. It's possible that this is what was happening when you ran firefox in the Terminal.

However, if Firefox had terminated but not yet been removed from the process table (which is what it means to be a zombie process / defunct process, and which I assume is what you mean by "ghost process"), a very new instance of Firefox should be able to recognize this and act like it's the only running instance of Firefox (because it is). If you find that this is not occurring, then you should report this behavior as a bug in the firefox package in Ubuntu (or against Firefox upstream if you're using the upstream distribution of Firefox rather than the version from official Ubuntu packages).

I don't know how much effort you're willing to put forth to figure out what's going on, but a window manager (compiz) crash shouldn't cause a Firefox window to be hidden, provided that compiz is actually started up again. If this does happen, that's a bug in compiz or firefox.

If you can provide the output of ps x | grep -v grep | grep firefox while the problem is occurring--i.e., after finding that running firefox in the Terminal returns you immediately to your shell--that would help greatly in troubleshooting this. You can edit your answer to include this information. You should also clarify if a new Firefox window/tab is opened when you run firefox in the Terminal, or if running it in the Terminal is having no effect.

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.