aboutsummaryrefslogtreecommitdiff
path: root/mailutils
diff options
context:
space:
mode:
Diffstat (limited to 'mailutils')
-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 @@
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
+#include <sys/prctl.h>
#include "libbb.h"
#include "mail.h"
-static void kill_helper(void)
-{
- if (G.helper_pid > 0) {
- kill(G.helper_pid, SIGTERM);
- G.helper_pid = 0;
- }
-}
-
// generic signal handler
static void signal_handler(int signo)
{
#define err signo
if (SIGALRM == signo) {
- kill_helper();
bb_error_msg_and_die("timed out");
}
@@ -66,16 +58,15 @@ void FAST_FUNC launch_helper(const char **argv)
// child stdout [1] -> parent stdin [0]
if (!G.helper_pid) {
- // child: try to execute connection helper
+ // child
+ // if parent dies, get SIGTERM
+ prctl(PR_SET_PDEATHSIG, SIGTERM, 0, 0, 0);
+ // try to execute connection helper
// NB: SIGCHLD & SIGALRM revert to SIG_DFL on exec
BB_EXECVP_or_die((char**)argv);
}
- // parent
- // check whether child is alive
- //redundant:signal_handler(SIGCHLD);
- // child seems OK -> parent goes on
- atexit(kill_helper);
+ // parent goes on
}
char* FAST_FUNC send_mail_command(const char *fmt, const char *param)