I launch applications from the Terminal with commands like this one :
/Applications/Mail.app/Contents/MacOS/Mail &
The important part is the &
.
-
For Unix / Linux / Solaris :
- I have learned at school that adding the
&
makes the program live on his own. - I strongly remember launching a command like
xeyes &
and having the program running safe even after I close the shell.
- I have learned at school that adding the
-
On Mac OS X (Unix inside) :
- I launch an app with
&
and I close the Terminal window : the application exits ! - Why does this undesirable behaviour happen on Mac OS X ?
- How can this be fixed ?
- I launch an app with
Best Answer
The "standard" way of accomplishing what you want to accomplish (on OS X as well as on Linux, FreeBSD or other systems) is to use the command
nohup
:This will start
program
, which will run in the background relative to the shell because of the&
- and will ignore hangup signals due to the nohup command.This way the program will continue running even though you close the shell. It doesn't matter if you're closing the shell because you're closing Terminal.app, or you're closing the shell because you are disconnecting from a ssh connection to the computer, or similar.