From 145abf1fcc8abe03f9bc06f1527e8b977f6247da Mon Sep 17 00:00:00 2001 From: Benji Wiebe Date: Thu, 27 Aug 2015 13:26:42 -0500 Subject: [PATCH 1/2] Kill children with HUP instead of TERM at end of session --- shellinabox/launcher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c index 08f1149..a9a886f 100644 --- a/shellinabox/launcher.c +++ b/shellinabox/launcher.c @@ -1700,8 +1700,8 @@ static void launcherDaemon(int fd) { errno = 0; NOINTR(pid = waitpid(request.terminate, &status, WNOHANG)); if (pid == 0 && errno == 0) { - if (kill(request.terminate, SIGTERM) == 0) { - debug("[server] Terminating child %d! [kill]", request.terminate); + if (kill(request.terminate, SIGHUP) == 0) { + debug("[server] Terminating child %d! [HUP]", request.terminate); } else { debug("[server] Terminating child %d failed! [%s]", request.terminate, strerror(errno)); From 7f5064efcd239fd29332a5b6ae19f197ed92873c Mon Sep 17 00:00:00 2001 From: Benji Wiebe Date: Thu, 27 Aug 2015 14:08:39 -0500 Subject: [PATCH 2/2] Reset sigaction for SIGHUP to default in child --- shellinabox/launcher.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c index a9a886f..20a4869 100644 --- a/shellinabox/launcher.c +++ b/shellinabox/launcher.c @@ -1629,6 +1629,10 @@ static void childProcess(struct Service *service, int width, int height, } } + // Reset the sigaction for HUP to the default, so the child does not inherit the action of SIG_IGN from us. + // We need the child to be able to get HUP's because we send HUP if the session times out/closes. + signal(SIGHUP, SIG_DFL); + // Finally, launch the child process. if (service->useLogin == 1) { // At login service launch, we try to pass real IP in '-h' parameter. Real