1. Job Control
Job control is a feature that BSD added in 1980. A job is just a collection of several processes. Job control requires support in the following three forms:
1). shell that supports job control (C shell is supported, and Bourne shell is not supported, but Korn shell is based on the situation ).
2) The Terminal Driver in the kernel must support job control.
3) The kernel must support some job control signals.
Three special characters can signal the Terminal Driver:
1). Interrupt characters (delete or Ctrl + C) generate Sigint.
2). Exit character (CTRL +/) to generate sigquit.
3). The Hanging character (CTRL + Z) generates sigtstp.
Only foreground jobs can be input by terminals. If the background job tries to read the control terminal, the signal sigttin is generated. This signal usually stops this background job temporarily, while shell sends a notification to the user about this situation, and then the user can use shell commands to convert the job to the foreground job for execution. Terminal I/O and terminal signals are always connected to the actual terminal from the foreground process group. For sigttou signals, the output of background process group processes is optional when they are released. As follows:
# Cat temp.txt & executed in the background
[1] 1986
# Output of background jobs after the hello World prompt
Enter
[1] + done cat temp.txt &
# Stty tostop disable background job output to control terminal
# Cat temp.txt & executed in the background
[1] 1989
# Output of background jobs after the hello World prompt
# Press enter to find that the job has been stopped
[1] + stopped (sigttou) Cat temp.txt &
# FG % 1 resume a stopped job on the foreground
Cat temp.txt shell tells us which job is in the foreground
Hello World: This is the output of the job.
2. Orphan Process Group
A parent process that has been terminated is called an orphan process, which is adopted by the INIT process.
Orphan Process Group Definition: the parent process of each member in the group is either a member of the group or a member of the session to which the Group belongs.
A process group is not an orphan process group. The group has a process whose parent process belongs to another group of the same session.