If _POSIX_JOB_CONTROL is defined, UNIX System V supports job-control and command interpreter processes supporting job-control can assign the terminal to different jobs, or process-groups, by placing related processes in a single process-group and assigning the process-group with the terminal. A process may examine or change the foreground process-group of a terminal assuming the process has the required permissions (see tcgetpgrp and tcsetpgrp in termios(3C)). The termios facility aids in this assignment by restricting access to the terminal by processes outside of the foreground process-group (see the sections on job control in ``Signals, job control and pipes'').
When there is no longer any process whose process-id or process-group-id matches the process-group-id of the foreground process-group, the terminal lacks any foreground process-group. It is unspecified whether the terminal has a foreground process-group when there is no longer any process whose process-group-id matches the process-group-id of the foreground process-group, but there is a process whose process-id matches the process-group-id of the foreground process-group. Only a successful call to tcsetpgrp or assignment of the controlling-terminal as described can make a process-group the foreground process-group of a terminal (see tcsetpgrp in termios(3C)).
Background process-groups in the session of the session-leader are subject to a job-control line-discipline when they attempt to access their controlling-terminal. Typically, they are sent a signal that causes them to stop, unless they have made other arrangements (see signal(5)). An exception is made for processes that belong to a orphaned process-group, which is a process-group none of whose members have a parent in another process-group within the same session and thus share the same controlling-terminal. When these processes attempt to access their controlling-terminal, they return errors, because there is no process to continue them if they should stop (see the sections on job control in ``Signals, job control and pipes'').