I don’t want to repeat the description how sessions, process groups, processes and threads all hang together in Linux. This description is pretty clear, there are plenty of others on the net.
I keep forgetting what’s the main feature of sessions and process groups though. So here is my reminder:
- A session can contain one or more process groups.
- A session can optionally have a controlling tty.
- Signals can be delivered to a process group.
- A shell with job control puts all processes of a pipe into one process group.
- Signals caused by the terminal (like Ctrl-C) go to all processes in the foreground process group.
The following ps command shows the relevant information from sessions down to threads.
ps -emo pid,ppid,sess,tty,pgid,tid,cls,rtprio,nice,cputime,comm,cmd