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
me@box:~$
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?
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 thefirefox
command again with a different URL (e.g., firefoxhttp://www.google.com
). When you examine running processes withps x
, you'll see that the only runningfirefox
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 thatcompiz
is actually started up again. If this does happen, that's a bug incompiz
orfirefox
.If you can provide the output of
ps x | grep -v grep | grep firefox
while the problem is occurring--i.e., after finding that runningfirefox
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 runfirefox
in the Terminal, or if running it in the Terminal is having no effect.