How do you automatically disown an application after you have started it from a terminal?
For example: if you start a terminal and run firefox
the application will start, but when you then close the terminal firefox will close as well. To avoid unintentionally closing applications that have been started from a terminal, one can first put them in the background with the ampersant: firefox &
which also restores the ability to use that terminal's prompt.
Next, you can disown the application from that same terminal using the process ID (PID) of the application, see this example below:
$ firefox &
$ ps | grep firefox
14917 pts/6 00:00:00 firefox
$ disown 14917
The application now runs independently from the terminal you are using, and closing the terminal will no longer terminate the application.
But how can you do this automatically each time you start an application?
startAndDisown
? How would you define “applications”?ps
is an application, just likefirefox
.