From 6ec61a43f30f7553d4a218bbb6c17cd4f88983a5 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Tue, 18 Oct 2016 13:34:03 -0400 Subject: [PATCH] Log more information about exited children When we receive a SIGCHLD, log more information about how the child processes that we reap terminated. Signed-off-by: Nalin Dahyabhai --- utils/utils.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 962a9949..dffbd92f 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -146,12 +146,24 @@ func StartReaper() { sig := <-sigs for { // Reap processes - cpid, _ := syscall.Wait4(-1, nil, syscall.WNOHANG, nil) + var status syscall.WaitStatus + cpid, err := syscall.Wait4(-1, &status, syscall.WNOHANG, nil) + if err != nil { + if err != syscall.ECHILD { + logrus.Debugf("wait4 after %v: %v", sig, err) + } + break + } if cpid < 1 { break } - - logrus.Debugf("Reaped process with pid %d %v", cpid, sig) + if status.Exited() { + logrus.Debugf("Reaped process with pid %d, exited with status %d", cpid, status.ExitStatus()) + } else if status.Signaled() { + logrus.Debugf("Reaped process with pid %d, exited on %s", cpid, status.Signal()) + } else { + logrus.Debugf("Reaped process with pid %d", cpid) + } } } }()