diff options
-rw-r--r-- | mailutils/mail.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/mailutils/mail.c b/mailutils/mail.c index 61e5053bc..f48b41bab 100644 --- a/mailutils/mail.c +++ b/mailutils/mail.c | |||
@@ -6,7 +6,13 @@ | |||
6 | * | 6 | * |
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | #include <sys/prctl.h> | 9 | #if defined(__linux__) |
10 | # include <sys/prctl.h> | ||
11 | # define PRCTL | ||
12 | #elif defined(__FreeBSD__) | ||
13 | # include <sys/procctl.h> | ||
14 | # define PROCCTL | ||
15 | #endif | ||
10 | #include "libbb.h" | 16 | #include "libbb.h" |
11 | #include "mail.h" | 17 | #include "mail.h" |
12 | 18 | ||
@@ -55,7 +61,14 @@ void FAST_FUNC launch_helper(const char **argv) | |||
55 | xmove_fd(child_in.rd, STDIN_FILENO); | 61 | xmove_fd(child_in.rd, STDIN_FILENO); |
56 | xmove_fd(child_out.wr, STDOUT_FILENO); | 62 | xmove_fd(child_out.wr, STDOUT_FILENO); |
57 | // if parent dies, get SIGTERM | 63 | // if parent dies, get SIGTERM |
64 | #if defined(PRCTL) | ||
58 | prctl(PR_SET_PDEATHSIG, SIGTERM, 0, 0, 0); | 65 | prctl(PR_SET_PDEATHSIG, SIGTERM, 0, 0, 0); |
66 | #elif defined(PROCCTL) | ||
67 | { | ||
68 | int signum = SIGTERM; | ||
69 | procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &signum); | ||
70 | } | ||
71 | #endif | ||
59 | // try to execute connection helper | 72 | // try to execute connection helper |
60 | // NB: SIGCHLD & SIGALRM revert to SIG_DFL on exec | 73 | // NB: SIGCHLD & SIGALRM revert to SIG_DFL on exec |
61 | BB_EXECVP_or_die((char**)argv); | 74 | BB_EXECVP_or_die((char**)argv); |