From 52dddd165a54669243c303839acdab89602d80e7 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sat, 10 Feb 2018 19:59:51 +0000 Subject: [PATCH] Mark as a subreaper on FreeBSD (as for Linux). This means double-forking processes become a child of Dinit rather than PID 1 (in case they are different). --- src/dinit.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/dinit.cc b/src/dinit.cc index 94dc61f..67474eb 100644 --- a/src/dinit.cc +++ b/src/dinit.cc @@ -17,6 +17,9 @@ #include #include #endif +#if defined(__FreeBSD__) || defined(__DragonFly__) +#include +#endif #include "dinit.h" #include "dasynq.h" @@ -324,6 +327,12 @@ int dinit_main(int argc, char **argv) // orphaned child will re-parent to us rather than to PID 1 (although that could be us too). prctl(PR_SET_CHILD_SUBREAPER, 1); #endif +#if defined(__FreeBSD__) || defined(__DragonFly__) + // Documentation (man page) for this kind of sucks. PROC_REAP_ACQUIRE "acquires the reaper status for + // the current process" but does that mean the first two arguments still need valid values to be + // supplied? We'll play itself and explicitly target our own process: + procctl(P_PID, getpid(), PROC_REAP_ACQUIRE); +#endif log_flush_timer.add_timer(event_loop, dasynq::clock_type::MONOTONIC); -- 2.25.1