Your Process Doesn't Exist Alone
Your Process Doesn't Exist Alone Sessions, Process Groups, and Why Ctrl-C Kills the Right Thing Reading time: ~13 minutes You pressed Ctrl-C and the program stopped. Exactly the right program. Not ...

Source: DEV Community
Your Process Doesn't Exist Alone Sessions, Process Groups, and Why Ctrl-C Kills the Right Thing Reading time: ~13 minutes You pressed Ctrl-C and the program stopped. Exactly the right program. Not its parent. Not the shell you typed from. The one you were running. That probably felt unremarkable. It shouldn't. The kernel had to figure out which processes — out of a structured hierarchy on your machine — deserved that signal. It got it right every time you've ever tried. There is infrastructure specifically designed to make that work, and it involves three layers of grouping you've never had to think about. Let's look at what's actually happening. The Problem Ctrl-C Has to Solve Here's a scenario. You type this: tar czf archive.tgz big_directory/ | pv | gpg --encrypt > archive.tgz.gpg Three processes. A pipeline. You get bored waiting and press Ctrl-C. Which one should die? All three. They're one operation from your perspective. The terminal agrees. Consider: you've spawned those thr