Using & specifically backgrounds the process so the shell is free to do other things, but the process is still a child of the current shell. You can prove this to yourself by running:
# print the shell's PID
echo $$
# background a process
sleep 25 &
# look at the sleep process's parent PID
ps -ef |grep sleep
The 'nohup' command tells the process to ignore SIGHUP, I don't believe this backgrounds the process so your shell is still locked while waiting on the process to finish. However when the parent shell is closed the HUP signal is sent to end it's child
processes, so `nohup some_cmd` prevents the child from being killed along with the parent. For this reason you will often see nohup used with backgrounded processes:
nohup sleep 25 &
The final result is a process that doesn't lock up your shell and doesn't end when it's parent (your shell) is terminated.
--
Paul Mooring
Systems Engineer and Customer Advocate
www.opscode.com
Behavior is different if you close the terminal emulator by calling 'exit' from within the session inside it than if you click the x in the corner or close the tab in Konsole. Without using something like nohup, even things launched in the background are
usually killed by clicking closing a terminal emulator from the outside. They stay open if you just log out of the session (at which point most terminal emulators just close themselves anyway).
Using nohup fixes this weirdness. It doesn't occur with processes that truly 'detach' themselves from the terminal, like those running inside screen and tmux sessions. I think this has something to do with the fact that closing a terminal emulator from the
GUI is more like killing the session than asking it to close, either backgrounded processes still associated with that (p)tty can't cope with that, or they count as 'child' processes and so they are implicated to and also receive whichever signal is used to
kill the terminal session.
Someone who really knows things about Unix shells can probably better explain the real mechanism of action here, but anyway, the behavior is different depending upon how the terminal emulator is closed.