3 ms·
One nitpick on disown: It will prevent the process from getting SIGHUP when the terminal is closed, but it won't change the pty or stdin/stdout/stderr of the p
by aidenn0 2y ago
One nitpick on disown:
It will prevent the process from getting SIGHUP when the terminal is closed, but it won't change the pty or stdin/stdout/stderr of the process, so it may still abort if/when I/O is performed. Using e.g. nohup solves this problem more completely. If you see programs abort even with disown, they are probably aborting on I/O errors to the terminal.
Also, some terminals (e.g. kitty) will not auto-close when bash exits if there are still processes having the PTY open. Here's a simple example to play around with to see some different possibilities (and check how your shell handles things). NB: It runs "exit" at the end, so run in a fresh terminal window/tab
{ set -e; rm -f /tmp/got-here; sleep 5; echo hi; touch /tmp/got-here; } 2>/tmp/test-stderr & disown; exit
If you run this in a terminal that doesn't close when your shell exits if any other process still has the pty open, then the tab/window will hang around for 5 seconds and then disappear; /tmp/got-here will exist. If you run in a terminal that does close when your shell exits (e.g. xterm), then /tmp/got-here will never be created and you'll see an IO error message in /tmp/test-stderr