From: Davin McCall Date: Sat, 10 Feb 2018 19:59:51 +0000 (+0000) Subject: Mark as a subreaper on FreeBSD (as for Linux). X-Git-Tag: v0.1.0~30 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=52dddd165a54669243c303839acdab89602d80e7;p=oweals%2Fdinit.git 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). --- 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);