--- a/bin/timeout/timeout.1 +++ b/bin/timeout/timeout.1 @@ -89,7 +89,11 @@ By default, .Dv SIGTERM is sent. .It Fl v , Fl -verbose -Show information to stderr about any signal sent on timeout. +Show information to +.Xr stderr 4 +about timeouts, signals to be sent, and the +.Ar command +exits. .El .Ss Duration Format The diff --git a/bin/timeout/timeout.c b/bin/timeout/timeout.c index c3c7532a9d08..8a2f0faecd83 100644 --- a/bin/timeout/timeout.c +++ b/bin/timeout/timeout.c @@ -344,6 +344,19 @@ main(int argc, char **argv) } else if (cpid == pid) { pstat = status; child_done = true; + logv("child terminated: pid=%d, " + "exit=%d, signal=%d", + (int)pid, WEXITSTATUS(status), + WTERMSIG(status)); + } else { + /* + * Collect grandchildren zombies. + * Only effective if we're a reaper. + */ + logv("collected zombie: pid=%d, " + "exit=%d, signal=%d", + (int)cpid, WEXITSTATUS(status), + WTERMSIG(status)); } } if (child_done) { @@ -361,9 +374,12 @@ main(int argc, char **argv) sig = killsig; sig_alrm = 0; timedout = true; + logv("time limit reached or received SIGALRM"); } else { sig = sig_term; sig_term = 0; + logv("received terminating signal %s(%d)", + sys_signame[sig], sig); } send_sig(pid, sig, foreground);