Programs like Skype and Tixati can just be called from the terminal without adding an &
at the end of their call. Why is this not the case with Firefox. I am just curious as to what programs I need to add the &
option to.
Programs like Skype and Tixati can just be called from the terminal without adding an &
at the end of their call. Why is this not the case with Firefox. I am just curious as to what programs I need to add the &
option to.
This depends entirely on how the software was written, often also depending on the intent with it.
Most bash (= shell, terminal) utilities are meant to be used "synchronously", with these the execution is meant to produce a result; which might be required for the following commands in a script or manual procedure - if the utility (program, software) detaches and leaves you at the prompt immediately you will not know when or if the result is available.
Skype is not normally used as a command line "utility" but rather a tool to handle communication (phone or whatever). And then it is quite handy if it does not block the terminal, if launched from there.
Detaching from the terminal:
https://superuser.com/questions/178587/how-do-i-detach-a-process-from-terminal-entirely
All programs can be called without
&
. The&
is completely optional. All it does is send the process to the background so you can continue using your terminal.Without it, if you launch a process from the terminal, you will need to wait until that process finishes (or is closed) before being able to continue using your terminal. Therefore, one often runs programs as
command &
to send them to the background and keep working in the same terminal.For more on the various shell operators like
&
and what they do, see here.It is very simple for a program to put itself in the background. The code used to do so could be as simple as this:
But doing so by default would introduce a few disadvantages. For example you could no longer wrap the program in a script which does something upon the program terminating. And writing output to the terminal from a background process could end up looking quite messy, terminal output from background processes can be disabled but then the background process will be frozen once it tries to produce output.
In my experience Skype and Firefox do not put themselves in the background. They do something different though.
When you start one of these programs they will check if there is already a running instance of the program. If there is a running instance the new instance will send a message to the running instance with the parameter you just gave it, and then quit.
The effect of that is that the already running instance does something, and you get your prompt back.