summaryrefslogtreecommitdiff
path: root/lib/daemon-unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/daemon-unix.c')
-rw-r--r--lib/daemon-unix.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/daemon-unix.c b/lib/daemon-unix.c
index 6169763c2..7e48630f0 100644
--- a/lib/daemon-unix.c
+++ b/lib/daemon-unix.c
@@ -15,6 +15,7 @@
*/
#include <config.h>
+#include "backtrace.h"
#include "daemon.h"
#include "daemon-private.h"
#include <errno.h>
@@ -75,7 +76,7 @@ static bool overwrite_pidfile;
static bool chdir_ = true;
/* File descriptor used by daemonize_start() and daemonize_complete(). */
-static int daemonize_fd = -1;
+int daemonize_fd = -1;
/* --monitor: Should a supervisory process monitor the daemon and restart it if
* it dies due to an error signal? */
@@ -291,8 +292,7 @@ fork_and_wait_for_startup(int *fdp, pid_t *child_pid)
OVS_NOT_REACHED();
}
}
- close(fds[0]);
- *fdp = -1;
+ *fdp = fds[0];
} else if (!pid) {
/* Running in child process. */
close(fds[0]);
@@ -313,8 +313,6 @@ fork_notify_startup(int fd)
if (error) {
VLOG_FATAL("pipe write failed (%s)", ovs_strerror(error));
}
-
- close(fd);
}
}
@@ -393,6 +391,8 @@ monitor_daemon(pid_t daemon_pid)
}
}
+ log_received_backtrace(daemonize_fd);
+
/* Throttle restarts to no more than once every 10 seconds. */
if (time(NULL) < last_restart + 10) {
VLOG_WARN("%s, waiting until 10 seconds since last "
@@ -508,7 +508,6 @@ daemonize_complete(void)
detached = true;
fork_notify_startup(daemonize_fd);
- daemonize_fd = -1;
daemonize_post_detach();
}
}