Avoid programs quitting when the terminal is closed

You might have noticed that, whenever you run a program from a terminal window, it quits when the terminal window is closed (there are some exceptions to this, such as the Firefox web browser, but it's generally the case). There are a handful of ways around this. Perhaps the easiest is to precede the command with nohup. For example, to run Gedit, you might type nohup gedit. Try this now. Then close the terminal window and see what happens (or, actually, what doesn't happen).

The reason Gedit doesn't quit is that nohup tells the new program to ignore any future "hangup signals", which is to say, Gedit is told ignore requests to terminate that are sent to it when the terminal quits.

See also Tip 207, on page 241, which describes how to use the screen command to create a command-line login that's independent of any terminal window.

Was this article helpful?

0 0

Post a comment