Lazyweb: POSIX Process Groups and Sessions

Post Syndicated from Lennart Poettering original https://0pointer.net/blog/projects/pgrp-vs-session.html

Dear Lazyweb,

I have trouble understanding what exactly POSIX process groups and sessions
are good for. The POSIX
docs
are very vague on this. What exactly is the effect of being in a process
group with some other process, and what does being in the same session with it
add on top? And what is the benefit of being a group/session leader in contrast of just being a normal random process in the group/session?

The only thing I understood is that kill(2) with a negative first
parameter can be used to “multicast” signals to entire process groups, and that
SIGINT on C-c is delivered that way. But, is that all? The POSIX docs say
… for the purpose of signaling, placement in foreground or background,
and other job control actions
“, which is very vague. What are those
other job control actions?“. What does job control persist of besides
multicasting signals? And what is “placement in foreground or background” other
than delivering signals?

And I totally don’t get POSIX sessions and how they differ from POSIX process groups. Please enlighten me!

Puzzled,
    Lennart