In particular, I created a script to start Firefox which I double-click and choose 'Run in terminal,' but when the shell exits Firefox is killed immediately.
How do I prevent this from happening?
In particular, I created a script to start Firefox which I double-click and choose 'Run in terminal,' but when the shell exits Firefox is killed immediately.
How do I prevent this from happening?
You need to put the nohup
before the command that launch firefox
, so it needs to looks like that:
>$ nohup firefox
Also Make sure you execute firefox as a background job and not as a front running since the shell is parent and is waiting for the firefox to run and exit before the prompt is to be returned.
Most solution what you find on the net, will run the firefox's script in a subshell. You will get the control back, after this subshell exits. If the firefox script runs in the background, you won't see its changes and variables set, and if its parent shell (your real shell) exits, it will probably still continue in the background.
The main reason behind that, that shells, including bash, have a make very clear difference between their
There is no easy way to change bash from a non-interactive script mode to an interactive one, after a script execution (this time, the firefox starter/wrapper script).
It would be possible, but as I know, no shell has support for this.
Fortunately, there many tricky ways to reach your goal:
bash --bashrc /here/is/what/i/want.sh
./here/is/what/i/want.sh
to re-execute its own interpreter, but this time already in interactive mode. This can be done with an exec /bin/bash -i
command. Simply put this to the end of your script.
bashrc
in your script can set environment variables needed by Firefox or other programs. – Garrett Hall Nov 30 '11 at 14:42