Ubuntu – Prevent an application from being closed on terminal exit

10.10bashcommand linenohup

I have created a bash script that starts an application. Since I wanted the terminal window to close when the application is started, I used this line:

firefox & 2> /dev/null; exit;

It works fine as long as I start the script from the command line. However, if I start it from a desktop laucher the application closes as well as the terminal. Can anyone explain why this is. Im using Ubuntu 10.10.

By only using:

    nohup firefox

it works. But I still would like an explanation to why the original version doesn't work when started from a desktop launcher, if possible.

Best Answer

The solution is to simply use the right form in the pipe:

firefox > /dev/null 2>&1
exit

This works both from terminal and from a desktop launcher. No need to use nohup.

Related Question