Possible Duplicate:
How do I prevent a script from terminating when the shell exits?

I use gnome-terminal, and I run emacs under the terminal in the background by executing emacs &, but after I close the terminal, emacs is also closed. How can I avoid this behavior? I know that emacs is a child process of the shell.

marked as duplicate by andcoz, manatwork, Michael Mrozek Jun 6 '12 at 15:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Check out GNU Screen. You can run something in the screen, then detach and disconnect and the script/program continues to run.

Link: http://www.gnu.org/software/screen/

Screen can be found in most distros. Ubuntu has a forked "Super" version of it available as well.


You can start emacs using the nohup command. nohup will run a command immune to hangups, with output to a non-tty

nohup emacs &

This will prevent the emacs process from terminating when the shell closes and the controlling terminal is destroyed.

You can get more information about nohup from info coreutils 'nohup invocation'

This is a nice discussion about nohup, disown, and &.

Not the answer you're looking for? Browse other questions tagged or ask your own question.