If anyone can suggest an update to <a href="https://github.com/oconnor663/duct.py/blob/master/gotchas.md#killing-grandchild-processes" rel="nofollow">https://github.com/oconnor663/duct.py/blob/master/gotchas.md...</a>, please let me know. As far as I'm aware, there's still no reliable way to kill a tree of processes on Unix that's suitable for library code.
All I ever wanted was to type ^C (or perhaps ^\) in my terminal and kill in one fell swoop all the shite that my previous shell-typed command spawned directly or indirectly.<p>This, IIRC used to be the standard behavior back in the days, but in recent years, for some reasons, things have not been so simple.<p>Looking at the man page of ps(1) sort of starts to elucidate the effing mess that the name "group" summons the in unix process world.<p>Are we talking about the real group id (RGID), the effective group id (EGID), the controlling progress group id (TPGID), the control group (CGROUP) the textual group id (EGROUP), the filesystem group id (FGID), the textual filesystem group id (FGID), the process id of the process group leader (PGID), the saved group id (SGID), the session id (SID), the supplementary group id (SUPGID), the thread group id (TGID) ?<p>I'm pretty sure I'm missing some.<p>What an effing mess.
If one is familiar with POSIX and why it is how it is, one knows that the reason that POSIX has both sessions and process groups is that "sessions" pretty much descend from AT&T System 3 process groups and "process groups" descend from BSD process groups; so one would indeed have expected that there were two separate ideas of "process group".<p>Things that this history does not cover include System 5 Release 2 "shell layers". Shell layers multiplexed virtual terminals onto a single physical terminal, preceding its obvious successors screen by somewhere around three years, and tmux by about quarter of a century. The popularity of tmux and screen nowadays shows that the BSD job control mechanism did not entirely kill off the vision of shell layers, as I recall people thinking it had at the time.
Process groups and job control is a huge fucking mess on Unix. Process groups, job control, and signals are probably the biggest mistakes of Unix's design. Arguably fork(2) as well, but that'll probably raise some eyebrows. The blame for Berkley sockets and ioctls can't entirely be laid at Unix's feet, but they're also quite the mess.
It’s a mess that originates from the dated concept of terminals and that users are necessarily bound with interactive sessions from them. Without the notion of terminals and special control sequences, process hierarchy control can be much simpler and more orthogonal. A “signal” would be sent to the leaf processes in the hierarchy first, then they terminate, notifying their parent and so on.