[gnome-builder/wip/lantw/fix-various-things-for-freebsd-and-clang: 4/4] git: support parent-death signal on FreeBSD



commit 0d3be3a1293329edd57b07a84f7b381cae4397b6
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Mon Jul 29 23:27:30 2019 +0800

    git: support parent-death signal on FreeBSD
    
    prctl is a Linux-only syscall, so using it unconditionally causes
    compilation error on FreeBSD. Fortunately, FreeBSD provides a similar
    function, procctl, which can be used for the same purpose.

 src/plugins/git/daemon/gnome-builder-git.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/git/daemon/gnome-builder-git.c b/src/plugins/git/daemon/gnome-builder-git.c
index 7e3a7baa9..df1817cb3 100644
--- a/src/plugins/git/daemon/gnome-builder-git.c
+++ b/src/plugins/git/daemon/gnome-builder-git.c
@@ -24,9 +24,16 @@
 #include <libgit2-glib/ggit.h>
 #include <stdlib.h>
 #include <signal.h>
-#include <sys/prctl.h>
 #include <unistd.h>
 
+#ifdef __linux__
+#include <sys/prctl.h>
+#endif
+
+#ifdef __FreeBSD__
+#include <sys/procctl.h>
+#endif
+
 #include "ipc-git-service.h"
 #include "ipc-git-service-impl.h"
 
@@ -76,7 +83,13 @@ main (gint argc,
   g_set_prgname ("gnome-builder-git");
   g_set_application_name ("gnome-builder-git");
 
+#ifdef __linux__
   prctl (PR_SET_PDEATHSIG, SIGTERM);
+#elif defined(__FreeBSD__)
+  procctl (P_PID, 0, PROC_PDEATHSIG_CTL, &(int){ SIGTERM });
+#else
+#error "Please submit a patch to support parent-death signal on your OS"
+#endif
 
   signal (SIGPIPE, SIG_IGN);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]