daemon: Report number of crashes on monitor process command line.
authorBen Pfaff <blp@nicira.com>
Tue, 21 Sep 2010 21:27:02 +0000 (14:27 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 23 Sep 2010 18:45:34 +0000 (11:45 -0700)
lib/daemon.c

index 5486504641b6ded5fa94dae6b5506be66a07ba0c..6b61879dbb76723a926dea8683716bc39eaacca7 100644 (file)
@@ -330,11 +330,13 @@ monitor_daemon(pid_t daemon_pid)
     const char *saved_program_name;
     time_t last_restart;
     char *status_msg;
+    int crashes;
 
     saved_program_name = program_name;
     program_name = xasprintf("monitor(%s)", program_name);
     status_msg = xstrdup("healthy");
     last_restart = TIME_MIN;
+    crashes = 0;
     for (;;) {
         int retval;
         int status;
@@ -352,7 +354,8 @@ monitor_daemon(pid_t daemon_pid)
         } else if (retval == daemon_pid) {
             char *s = process_status_msg(status);
             free(status_msg);
-            status_msg = xasprintf("pid %lu died, %s",
+            status_msg = xasprintf("%d crashes: pid %lu died, %s",
+                                   ++crashes,
                                    (unsigned long int) daemon_pid, s);
             free(s);