summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2025-01-19 15:16:02 -0800
committerVito Caputo <vcaputo@pengaru.com>2025-01-19 15:16:02 -0800
commitba3653f6e500f32385f766e308264357631db8b5 (patch)
treed31e3823998d9801ed165c8a4db42d7cd2d86167
parent3a29d7bc88ab258e1a864f1932ba08380199125c (diff)
vmon: introduce -R/--reaper flag
Beginnings of PR_SET_CHILD_SUBREAPER mode, this only adds the CLI flags. Becoming a subreaper is only relevant to running commands via vmon. If the commands being executed fork/exec/daemonize or otherwise may produce orphaned processes, they escape the scoped hierarchical monitoring when init inherits them, so you lose visibility into their actions once orphaned. By becoming a subreaper, vmon can be the process inheriting those orphans, so they may continue being monitored, as if vmon were init, for its descendants.
-rw-r--r--src/vmon.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/vmon.c b/src/vmon.c
index e49b360..059bcd5 100644
--- a/src/vmon.c
+++ b/src/vmon.c
@@ -49,6 +49,7 @@ typedef struct vmon_t {
int linger;
int dump_procs;
int mem_locked;
+ int reaper;
time_t start_time;
int snapshots_interval;
int snapshot;
@@ -205,6 +206,7 @@ static void print_help(void)
" -v --version Print version\n"
" -D --dump-procs Dump libvmon internal processes table (debugging aid)\n"
" -L --mem-locked Lock in memory using mlockall(MCL_CURRENT|MCL_FUTURE)\n"
+ " -R --reaper Become the child subreaper (see prctl(2); PR_SET_CHILD_SUBREAPER)\n"
" -W --width Chart width\n"
" -z --hertz Sample rate in hertz\n"
"-------------------------------------------------------------------------------"
@@ -498,6 +500,9 @@ static int vmon_handle_argv(vmon_t *vmon, int argc, const char * const *argv)
} else if (is_flag(*argv, "-L", "--mem-locked")) {
vmon->mem_locked = 1;
last = argv;
+ } else if (is_flag(*argv, "-R", "--reaper")) {
+ vmon->reaper = 1;
+ last = argv;
} else if ((*argv)[0] == '-') {
VWM_ERROR("Unrecognized argument: \"%s\", try --help\n", argv[0]);
exit(EXIT_FAILURE);
© All Rights Reserved