unix/JobControlShellDifference written at 23:42:18; Add Comment
The difference between shells that do job control and shells that don't
Apart from having job control, the difference between a job control shell and a non job control shell is that job control shells put each command into a difference process group. They do this even for commands running in the foreground, because you may later want to ^Z the command and push it into the background, and process groups are the core mechanism of doing job control.
(Process groups do two things in job control. First, they let the shell
reliably send stop or start signals to all of the processes spawned
by a command. Second, they control what processes can do IO with the
terminal; only processes in the foreground process group can read from
the terminal, and you can use '
Shells that don't do job control just ignore process groups and thus leave all commands in the current process group (which is also the foreground process group).
This matters because of what happens when you end a session. When a
terminal closes (either a pty or a real terminal), only the current
foreground process group is sent a
(So how do suspended processes get cleaned up when you log out? There's
a second mechanism: orphaned process groups that have one or more
suspended processes are sent
Since there are very few shells these days that don't do job control,
this may be a hard error for people to see in testing. But it's really
not hard to see in code; the rule is that if you want a process to
survive the session ending, you must take explicit steps to insulate
(A recent correction got me interested in all of this.)
* * *
Atom feeds are available; see the bottom of most pages.