Process group
Every process have a process id and a process group id
Every process group have a leader process[id is same as group]
Each process in group have relations, like a family tree.
All processes’ root is init process which id is 1
Process group will exist when process exist in group.
1 | pi@raspberrypi:~ $ ps axj |grep "\s1\s" |
Jobs
Shell control frontground and background by job or process group but not process.
A job can be composed by one or more process group.
A shell can run a frontground job and multi background jobs.
Use pip command | run multi process, & make job background.
1 | pi@raspberrypi:~ $ sleep 1000|more|less & |
Difference between job and process group:
Sub process not belong to main process’s job alone.
Session
Session composed by one or more process group.[job?]
A session can have control terminal.
Builde a connection and connect with terminal’s session fist
process be called the control process bash in normal.
- one control process
bash - one frontground process
- any number background process
Job control
job control is new charcter be added in 1980 by BSD.
It allow terminal execute multi process group.
- need job control shell
- kernal’s terminal driver support job control
- kernal support job’s control signal
Signal
| name | opt | signal |
|---|---|---|
| Interrupt | Ctrl + c | SIGINT |
| Quit | Ctrl + \ | SIGQUIT |
| Hang up | Ctrl + z | SIGSTP |
Input Output
Only frontground process can read terminal’s input data.
When background process want to read data from terminal
it is not a error behaviour, just not be allowed.
When kernal driver detected background process want read
it will send a SIGTSTP signal to background job to stop process.
Then use fg command change process to front and run
[change to front and put SIGCONT signal to this group]
Background process write data to terminal can be selfdefinestty tostop command formidden background write data to terminal.
1 |
|