commit:     94077d264e14783e6ca5603d64e9d579fb206c20
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon May 23 16:06:40 2016 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon May 23 16:10:51 2016 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=94077d26

supervise-daemon: log the exit code or signal when a child process dies

 src/rc/supervise-daemon.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 2d8287f..c1ef169 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -702,8 +702,12 @@ int main(int argc, char **argv)
                                syslog(LOG_INFO, "stopping %s, pid %d", exec, 
child_pid);
                                kill(child_pid, SIGTERM);
                        } else {
-                               syslog(LOG_INFO, "%s, pid %d, terminated 
unexpectedly",
-                                               exec, child_pid);
+                               if (WIFEXITED(i))
+                                       syslog(LOG_INFO, "%s, pid %d, exited 
with return code %d",
+                                                       exec, child_pid, 
WEXITSTATUS(i));
+                               else if (WIFSIGNALED(i))
+                                       syslog(LOG_INFO, "%s, pid %d, 
terminated by signal %d",
+                                                       exec, child_pid, 
WTERMSIG(i));
                                child_pid = fork();
                                if (child_pid == -1)
                                        eerrorx("%s: fork: %s", applet, 
strerror(errno));

Reply via email to