From c9319fbef5b9c2dbf1f9c58b040e20d709c69fb0 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Fri, 7 Jul 2006 09:18:05 +0000 Subject: [PATCH] Make flow of execution clearer for getting process exit status --HG-- extra : convert_revision : 9a15e5205a3fd8ac4d23118f1857db9fa9d58a90 --- svr-chansession.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/svr-chansession.c b/svr-chansession.c index fed8240..b8f939b 100644 --- a/svr-chansession.c +++ b/svr-chansession.c @@ -88,6 +88,8 @@ static void sesssigchild_handler(int UNUSED(dummy)) { TRACE(("enter sigchld handler")) while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { + + exit = NULL; /* find the corresponding chansess */ for (i = 0; i < svr_ses.childpidsize; i++) { if (svr_ses.childpids[i].pid == pid) { @@ -99,7 +101,7 @@ static void sesssigchild_handler(int UNUSED(dummy)) { /* If the pid wasn't matched, then we might have hit the race mentioned * above. So we just store the info for the parent to deal with */ - if (i == svr_ses.childpidsize) { + if (!exit) { exit = &svr_ses.lastexit; } @@ -118,7 +120,6 @@ static void sesssigchild_handler(int UNUSED(dummy)) { /* we use this to determine how pid exited */ exit->exitsignal = -1; } - exit = NULL; }