aboutsummaryrefslogtreecommitdiff
path: root/mailutils/mail.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-08-22 14:56:12 +0100
committerRon Yorston <rmy@pobox.com>2017-08-22 14:56:12 +0100
commitce9af1cc5ea23f754587448cf35b5120c77bfeef (patch)
tree69e5eaba5e75ab909ed92d5045393471b8ff3c13 /mailutils/mail.c
parentc170026700eabb10147dd848c45c06995b43a32e (diff)
parente837a0dbbebf4229306df98fe9ee3b9bb30630c4 (diff)
downloadbusybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.tar.gz
busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.tar.bz2
busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'mailutils/mail.c')
-rw-r--r--mailutils/mail.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/mailutils/mail.c b/mailutils/mail.c
index a7e43c0d1..eceb89071 100644
--- a/mailutils/mail.c
+++ b/mailutils/mail.c
@@ -6,23 +6,15 @@
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#include "libbb.h" 10#include "libbb.h"
10#include "mail.h" 11#include "mail.h"
11 12
12static void kill_helper(void)
13{
14 if (G.helper_pid > 0) {
15 kill(G.helper_pid, SIGTERM);
16 G.helper_pid = 0;
17 }
18}
19
20// generic signal handler 13// generic signal handler
21static void signal_handler(int signo) 14static void signal_handler(int signo)
22{ 15{
23#define err signo 16#define err signo
24 if (SIGALRM == signo) { 17 if (SIGALRM == signo) {
25 kill_helper();
26 bb_error_msg_and_die("timed out"); 18 bb_error_msg_and_die("timed out");
27 } 19 }
28 20
@@ -66,16 +58,15 @@ void FAST_FUNC launch_helper(const char **argv)
66 // child stdout [1] -> parent stdin [0] 58 // child stdout [1] -> parent stdin [0]
67 59
68 if (!G.helper_pid) { 60 if (!G.helper_pid) {
69 // child: try to execute connection helper 61 // child
62 // if parent dies, get SIGTERM
63 prctl(PR_SET_PDEATHSIG, SIGTERM, 0, 0, 0);
64 // try to execute connection helper
70 // NB: SIGCHLD & SIGALRM revert to SIG_DFL on exec 65 // NB: SIGCHLD & SIGALRM revert to SIG_DFL on exec
71 BB_EXECVP_or_die((char**)argv); 66 BB_EXECVP_or_die((char**)argv);
72 } 67 }
73 68
74 // parent 69 // parent goes on
75 // check whether child is alive
76 //redundant:signal_handler(SIGCHLD);
77 // child seems OK -> parent goes on
78 atexit(kill_helper);
79} 70}
80 71
81char* FAST_FUNC send_mail_command(const char *fmt, const char *param) 72char* FAST_FUNC send_mail_command(const char *fmt, const char *param)