bash-4.3$ ps -j | cat
PID PGID SID TTY TIME CMD
4586 4586 4586 pts/1 00:00:00 bash
4600 4600 4586 pts/1 00:00:00 ps
4601 4600 4586 pts/1 00:00:00 cat
bash-4.3$ ps -j; ps -j
PID PGID SID TTY TIME CMD
4586 4586 4586 pts/1 00:00:00 bash
4602 4602 4586 pts/1 00:00:00 ps
PID PGID SID TTY TIME CMD
4586 4586 4586 pts/1 00:00:00 bash
4603 4603 4586 pts/1 00:00:00 ps
An interactive shell job is inplemented with a process group. That's what process groups have been created for: run interactive shell jobs. Interactive shells are about the only commands that actually mingle with process groups.
Above ps -j | cat
is a (foreground) job. Both ps
and cat
are in the same process group, the shell made it the foreground process group of the terminal, so that a ^C
causes a SIGINT to be sent to them.
In the second example, two consecutive jobs.
In
bash-4.3$ (ps -j; ps -j)
PID PGID SID TTY TIME CMD
4586 4586 4586 pts/1 00:00:00 bash
4633 4633 4586 pts/1 00:00:00 bash
4634 4633 4586 pts/1 00:00:00 ps
PID PGID SID TTY TIME CMD
4586 4586 4586 pts/1 00:00:00 bash
4633 4633 4586 pts/1 00:00:00 bash
4635 4633 4586 pts/1 00:00:00 ps
The subshell is one job. The subshell itself could be seen as a non-interactive shell.