steamcompmgr: reap children like Linux on some BSDs

DragonFly and FreeBSD adopted a similar API to Linux. Other sytems
maybe interested as well, so add a warning.

src/steamcompmgr.cpp:51:10: fatal error: 'sys/prctl.h' file not found
 #include <sys/prctl.h>
         ^~~~~~~~~~~~~
src/steamcompmgr.cpp:3118:9: error: use of undeclared identifier 'PR_SET_CHILD_SUBREAPER'
        prctl( PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0 );
               ^
This commit is contained in:
Jan Beich 2020-10-26 05:52:12 +00:00 committed by Joshie
parent 241df252fd
commit 50d5ea83b6

View file

@ -53,7 +53,11 @@
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/types.h>
#if defined(__linux__)
#include <sys/prctl.h>
#elif defined(__DragonFly__) || defined(__FreeBSD__)
#include <sys/procctl.h>
#endif
#include <sys/socket.h>
#include <sys/resource.h>
#include <time.h>
@ -4832,8 +4836,14 @@ void check_new_wayland_res(xwayland_ctx_t *ctx)
static void
spawn_client( char **argv )
{
#if defined(__linux__)
// (Don't Lose) The Children
prctl( PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0 );
#elif defined(__DragonFly__) || defined(__FreeBSD__)
procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL);
#else
#warning "Changing reaper process for children is not supported on this platform"
#endif
std::string strNewPreload;
char *pchPreloadCopy = nullptr;