aboutsummaryrefslogtreecommitdiff
path: root/lib/daemon.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-11-23 12:15:42 -0800
committerBen Pfaff <blp@nicira.com>2011-11-28 12:33:34 -0800
commit2c8fcc9cd6a7bbb948f6c79879e89c7ed791c9b1 (patch)
treef07cbb03ab1902ccd6897fbed6ef156add671a3c /lib/daemon.c
parent2c5a6834513540a494bfb3bfc48b8a91c4126a11 (diff)
daemon: Better log when fork child dies early from signals.
On one machine, "/etc/init.d/openvswitch-switch start" failed to start with: ovs-vswitchd: fork child failed to signal startup (Success) Starting ovs-vswitchd ... failed! "strace" revealed that the fork child was actually segfaulting, but the message output didn't indicate that in any way. This commit fixes the log message (but not the segfault itself). Reported-by: Michael Hu <mhu@nicira.com> Bug #8457.
Diffstat (limited to 'lib/daemon.c')
-rw-r--r--lib/daemon.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/daemon.c b/lib/daemon.c
index ef1a24ef..3dd5a1ab 100644
--- a/lib/daemon.c
+++ b/lib/daemon.c
@@ -250,16 +250,21 @@ fork_and_wait_for_startup(int *fdp)
retval = waitpid(pid, &status, 0);
} while (retval == -1 && errno == EINTR);
- if (retval == pid
- && WIFEXITED(status)
- && WEXITSTATUS(status)) {
- /* Child exited with an error. Convey the same error to
- * our parent process as a courtesy. */
- exit(WEXITSTATUS(status));
+ if (retval == pid) {
+ if (WIFEXITED(status) && WEXITSTATUS(status)) {
+ /* Child exited with an error. Convey the same error
+ * to our parent process as a courtesy. */
+ exit(WEXITSTATUS(status));
+ } else {
+ char *status_msg = process_status_msg(status);
+ VLOG_FATAL("fork child died before signaling startup (%s)",
+ status_msg);
+ }
+ } else if (retval < 0) {
+ VLOG_FATAL("waitpid failed (%s)", strerror(errno));
+ } else {
+ NOT_REACHED();
}
-
- VLOG_FATAL("fork child failed to signal startup (%s)",
- strerror(errno));
}
close(fds[0]);
*fdp = -1;