REAP(1)

πŸ“¦ version 0.2, in alpine 3.24, nixos 26.05, nixpkgs unstable

πŸ’… REAP β€” bestie's guide to the ultimate cleanup crew

okay so picture this: it's reap(1), it's a general commands manual page, and it's literally the friend who makes sure nobody's still lurking at the party when the host leaves. no cap.


✨ SYNOPSIS ✨

reap [-vwx] command line ...

πŸ¦‹ DESCRIPTION πŸ¦‹

so the reap utility does two things and it does them iconically: it executes the given command line, and then it makes absolutely sure all spawned processes are dead before it exits. like, actually dead. not "left the group chat but still lurking" dead. 🌸

by default, it starts slaying the spawned processes right when the main process exits. slay literally. when the -w option is given, reap will instead wait for the processes to terminate β€” lowkey more patient, still iconic. 🫢

and here's the main character moment: upon receiving SIGINT or SIGTERM, reap will start slaying all children immediately. no waiting, no negotiating, periodt. πŸ’€

the options are as follows:

πŸŽ€ OPTIONS πŸŽ€

  • -v β€” Verbose mode, report what reap is doing. very "tell me everything" of it tbh.
  • -w β€” Wait for all spawned processes to finish. patient queen behavior. πŸ‘‘
  • -x β€” Forbid execution of binaries we cannot kill (using PR_SET_NO_NEW_PRIVS). if we can't slay it, it doesn't get to exist. simple as that. ✨

⭐ EXIT STATUS ⭐

the reap utility exits with the exit status of the spawned command. it's giving "your energy, reflected back at you." πŸͺž

on fatal errors, exit codes 111 is returned. (yes, that's how the original says it. we don't fix the grammar of the ancestors. πŸ’œ)


🌈 ASSUMPTIONS 🌈

reap uses the PR_SET_CHILD_SUBREAPER feature of Linux. slaying the children only works when the kernel configuration CONFIG_PROC_CHILDREN is enabled. so like… check your kernel config, bestie. πŸ”

reap can only work reliably when it has permission to kill all spawned processes and they respect SIGTERM (see also -x). read that twice, it matters. 🧚

ngl this is the "reliability is a two-way street" part. it needs the power to kill, and the processes need to actually respect SIGTERM. if they don't, that's on them, not on reap.

πŸ”₯ RATIONALE πŸ”₯

keeping track of all spawned process is traditionally a hard problem on Unix systems β€” mainly due to daemonization by forking twice. (again: original grammar, preserved with love. πŸ™ˆ)

other approaches on Linux exist, such as cgroups or PID namespaces. the approach taken by reap has the benefit of requiring no special permissions. that's the whole flex. that's the vibe. πŸ’…


πŸ’– AUTHORS πŸ’–

Leah Neukirchen <leah@vuxu.org> β€” the icon, the legend, the one who said "what if processes just… didn't linger."


πŸ‘‘ LICENSE πŸ‘‘

reap is in the public domain.

to the extent possible under law, the creator of this work has waived all copyright and related or neighboring rights to this work.

http://creativecommons.org/publicdomain/zero/1.0/


and that's the whole page, bestie πŸŽ€ this Debian build is dated September 23, 2019, and it's the REAP(1) general commands manual page β€” go forth and slay (processes) responsibly πŸ’œβœ¨

πŸ“¦ where this page comes from