Send a signal to a whole process group from the shell to stop related workers at once. 02.12.2025 | reading time: 3 min When a tree of related processes must go down together, sending a signal to the whole process group is the right tool; this guide shows how to target the group from the shell and why it matters. Live demo Here is a concrete session that creates a process group and then kills it as a unit: ```sh -c 'sleep 300 & sleep 400 & wait' & echo $! 12345 ps -o pid,pgid,cmd -p 12345 12345 12345 sh -c sleep 300 & sleep 400 & wait ps -eo pid,pgid,cmd | awk '$2==12345' 12346 12345 sleep 300 12347 12345 sleep 400 kill -- -12345 ``` The key step is the negative PID form: `kill -- -PGID` sends the signal to every process whose process group ID equals PGID, so one command cleans up all members. Signals and safety Always start with a polite signal such as SIGTERM so processes can shut down cleanly, then escalate to SIGKILL only if they ignore termination; use `kill -s SIGTERM -- -$PGID` to be explicit, and remember `kill -- -$PGID` requires root or the same user that owns the processes. When groups matter Process groups are created by shells, sessions, and utilities like `setsid`; they let pipelines and background workers share job-control boundaries, so use groups to manage entire pipelines, supervise worker pools, or clean up orphaned children spawned by a crashed supervisor. Related utilities You will often combine `kill -- -PGID` with tools like `ps` or `pgrep` to discover PGIDs, or use `pkill -g PGID` when available; for supervised services prefer the supervisor's stop command or systemd to avoid races. Wrap-up and next steps Targeting a process group is a simple, powerful primitive: learn to inspect PGIDs, prefer graceful signals, and automate safe cleanup in scripts; if you want to deepen your Linux skills and prepare for certification consider intensive exam preparation such as CompTIA Linux+ or LPIC-1 training at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. processes utilities scripting troubleshooting