From bd3f0bd9fdf3f50da29de21ca27c9482538f8212 Mon Sep 17 00:00:00 2001 From: KLuka Date: Tue, 13 Jan 2015 13:04:01 +0100 Subject: [PATCH] Debug info and minor fix on child process exit (service exit) * Added debug information when child process exits - pid of child process (service) - exit code (this should help for debuging issues related to "Session closed") * Fixed status checking from waitpid() when child process exits - before we were checking wrong variable (checks were allways true) - now we use correct status variable --- shellinabox/launcher.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c index 68d8862..69e29e6 100644 --- a/shellinabox/launcher.c +++ b/shellinabox/launcher.c @@ -1616,7 +1616,8 @@ static void launcherDaemon(int fd) { int status; pid_t pid; while (NOINTR(pid = waitpid(-1, &status, WNOHANG)) > 0) { - if (WIFEXITED(pid) || WIFSIGNALED(pid)) { + debug("Child %d exited with exit code %d\n", pid, WEXITSTATUS(status)); + if (WIFEXITED(status) || WIFSIGNALED(status)) { char key[32]; snprintf(&key[0], sizeof(key), "%d", pid); deleteFromHashMap(childProcesses, key); @@ -1636,7 +1637,8 @@ static void launcherDaemon(int fd) { break; } while (NOINTR(pid = waitpid(-1, &status, WNOHANG)) > 0) { - if (WIFEXITED(pid) || WIFSIGNALED(pid)) { + debug("Child %d exited with exit code %d\n", pid, WEXITSTATUS(status)); + if (WIFEXITED(status) || WIFSIGNALED(status)) { char key[32]; snprintf(&key[0], sizeof(key), "%d", pid); deleteFromHashMap(childProcesses, key);