I like to start GUI programs from the terminal, e.g. emacs myfile.txt
. But doing that leaves a terminal window open with that process, so now there are two windows for me to keep track of. And if I close the terminal window, the GUI program closes.
I know I can run exec cmd
, where cmd
is the command I'm trying to run, and that closes the terminal window after the program completes. But I want to close the terminal window after the command is launched. Is there a way to do that?
&& exit
to any command you expect to end succesfully. In your case,emacs myfile.txt && exit
. – Stewart May 16 '20 at 19:15disown
be needed only if the shell (Bash) were a login interactive shell and withhuponexit
enabled? I would expect everything to work just fine by running the command in the background alone, and then exit from the shell immediately. The kernel should not send SIGHUP to the command because it is in the background. – LL3 May 17 '20 at 00:33exit
, its windows should close gracefully without sending SIGHUP to Bash. As such, Bash would not re-send any signal as it didn’t receive any signal. And the kernel won't SIGHUP the Emacs as it's been run in the background. – LL3 May 17 '20 at 13:27exit
that's true (would not be true withkill -s SIGHUP
, but of course not the case here), sorry for misreading your question and thank you for pointing that out. Even though it is very unlikely that someone will have both the login shell andhuponexit
enabled, I'm leavingdisown
there because it is more general. – Quasímodo May 17 '20 at 14:11