[ovs-dev] [PATCH] daemon: Don't imply that a normal exit from the monitor is a crash.

Ben Pfaff blp at nicira.com
Fri Oct 22 09:34:12 PDT 2010


When the monitored child is killed with SIGTERM, the monitoring process
currently logs a message like "1 crashes: pid 12345 died, killed by
signal 15 (Terminated), exiting".  This counts the SIGTERM as a crash, even
though it's intentional.

This commit changes the log message to omit the "%d crashes" part on normal
termination.
---
 lib/daemon.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/daemon.c b/lib/daemon.c
index bc28973..7f2c150 100644
--- a/lib/daemon.c
+++ b/lib/daemon.c
@@ -367,13 +367,13 @@ monitor_daemon(pid_t daemon_pid)
             ovs_fatal(errno, "waitpid failed");
         } else if (retval == daemon_pid) {
             char *s = process_status_msg(status);
-            free(status_msg);
-            status_msg = xasprintf("%d crashes: pid %lu died, %s",
-                                   ++crashes,
-                                   (unsigned long int) daemon_pid, s);
-            free(s);
-
             if (should_restart(status)) {
+                free(status_msg);
+                status_msg = xasprintf("%d crashes: pid %lu died, %s",
+                                       ++crashes,
+                                       (unsigned long int) daemon_pid, s);
+                free(s);
+
                 if (WCOREDUMP(status)) {
                     /* Disable further core dumps to save disk space. */
                     struct rlimit r;
@@ -407,7 +407,8 @@ monitor_daemon(pid_t daemon_pid)
                     break;
                 }
             } else {
-                VLOG_INFO("%s, exiting", status_msg);
+                VLOG_INFO("pid %lu died, %s, exiting",
+                          (unsigned long int) daemon_pid, s);
                 exit(0);
             }
         }
-- 
1.7.1





More information about the dev mailing list