As a result of the termination of the shell, POSIX.1-2008 requires:
If the exit of the process causes a process group to become orphaned, and if any member of the newly-orphaned process group is stopped, then a SIGHUP signal followed by a SIGCONT signal shall be sent to each process in the newly-orphaned process group.
The default action on receipt of SIGHUP is to terminate the process. However, depending on the shell and how the process was started, as well as any signal handling set up by the process itself, SIGHUP may be ignored by the process. In that case the process will continue normal execution.
The assumption is that processes in a process group, running under a job control shell, will be manipulated by that shell as a group, and not by the user sending direct SIGSTOP and SIGCONT signals. POSIX.1-2008 explains:
...if the termination of a process causes a process group to become orphaned, processes within the group are disconnected from their job control shell, which no longer has any information on the existence of the process group. Stopped processes within the group would languish forever. In order to avoid this problem, newly orphaned process groups that contain stopped processes are sent a SIGHUP signal and a SIGCONT signal to indicate that they have been disconnected from their session. The SIGHUP signal causes the process group members to terminate unless they are catching or ignoring SIGHUP. Under most circumstances, all of the members of the process group are stopped if any of them are stopped.
A process could avoid this behavior by forking and creating its own session (setsid()
), so that it would no longer be part of the session of the shell where it was started. It would then not be affected by job control within the shell, by the shell's termination, or by signals generated from the terminal.