Switch to side-by-side view

--- a/src/execmd.cpp
+++ b/src/execmd.cpp
@@ -270,16 +270,39 @@
         // this case, we have to conclude that the child process does
         // not exist. Not too sure what causes this, but the previous code
         // definitely tried to call killpg(-1,) from time to time.
-        pid_t grp;
+        pid_t grp, w;
         if (m_parent->m_pid > 0 && (grp = getpgid(m_parent->m_pid)) > 0) {
             LOGDEB("ExecCmd: pid " << m_parent->m_pid << " killpg(" << grp <<
                    ", SIGTERM)\n");
             int ret = killpg(grp, SIGTERM);
             if (ret == 0) {
+                int status;
                 for (int i = 0; i < 3; i++) {
                     msleep(i == 0 ? 5 : (i == 1 ? 100 : 2000));
-                    int status;
-                    (void)waitpid(m_parent->m_pid, &status, WNOHANG);
+                    do {
+                        w = waitpid(m_parent->m_pid, &status, WNOHANG);
+                        if (w == -1) {
+                            LOGERR("ExecCmd: error waitpid (" <<
+                                    m_parent->m_pid << ")" << endl);
+                        } else {
+                            if (WIFEXITED(status)) {
+                                LOGDEB("ExecCmd: " << m_parent->m_pid <<
+                                        " exited, status=" <<
+                                        WEXITSTATUS(status) << endl);
+                            } else if (WIFSIGNALED(status)) {
+                                LOGDEB("ExecCmd: " << m_parent->m_pid <<
+                                        " killed by signal " <<
+                                        WTERMSIG(status) << endl);
+                            } else if (WIFSTOPPED(status)) {
+                                LOGDEB("ExecCmd: " << m_parent->m_pid <<
+                                        " stopped by signal " <<
+                                        WSTOPSIG(status) << endl);
+                            } else if (WIFCONTINUED(status)) {
+                                LOGDEB("ExecCmd: " << m_parent->m_pid <<
+                                        " continued" << endl);
+                            }
+                        }
+                    } while (!WIFEXITED(status) && !WIFSIGNALED(status));
                     if (kill(m_parent->m_pid, 0) != 0) {
                         break;
                     }