[PATCH] Fix mail compilation on the FreeBSD
Alex Samorukov
samm at os2.kiev.ua
Mon Jan 4 00:18:44 UTC 2021
FreeBSD using procctl instead of Linux prctl
Signed-off-by: Alex Samorukov <samm at os2.kiev.ua>
---
mailutils/mail.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/mailutils/mail.c b/mailutils/mail.c
index 61e5053bc..7ed58593f 100644
--- a/mailutils/mail.c
+++ b/mailutils/mail.c
@@ -6,7 +6,13 @@
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
+#ifdef __Linux__
#include <sys/prctl.h>
+#define PRCTL
+#elif defined(__FreeBSD__)
+#include <sys/procctl.h>
+#define PROCCTL
+#endif
#include "libbb.h"
#include "mail.h"
@@ -55,7 +61,12 @@ void FAST_FUNC launch_helper(const char **argv)
xmove_fd(child_in.rd, STDIN_FILENO);
xmove_fd(child_out.wr, STDOUT_FILENO);
// if parent dies, get SIGTERM
- prctl(PR_SET_PDEATHSIG, SIGTERM, 0, 0, 0);
+ int signum = SIGTERM;
+#ifdef PRCTL
+ prctl(PR_SET_PDEATHSIG, signum, 0, 0, 0);
+#elif defined PROCCTL
+ procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &signum);
+#endif
// try to execute connection helper
// NB: SIGCHLD & SIGALRM revert to SIG_DFL on exec
BB_EXECVP_or_die((char**)argv);
--
2.29.1
More information about the busybox
mailing list