From 065de90380c88d9fcc116627f714bed9984c2723 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 7 Aug 2009 11:13:49 -0700 Subject: all: check return value from daemon() call * */*main.c: (main) Current versions of Gcc warn if the return value for daemon() is not checked. So add a simple test and exit on failure. --- zebra/main.c | 7 +++++-- zebra/test_main.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'zebra') diff --git a/zebra/main.c b/zebra/main.c index 2d6a4ac8..d829c046 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -362,8 +362,11 @@ main (int argc, char **argv) exit (0); /* Daemonize. */ - if (daemon_mode) - daemon (0, 0); + if (daemon_mode && daemon (0, 0) < 0) + { + zlog_err("Zebra daemon failed: %s", strerror(errno)); + exit (1); + } /* Output pid of zebra. */ pid_output (pid_file); diff --git a/zebra/test_main.c b/zebra/test_main.c index e186fea6..4398a389 100644 --- a/zebra/test_main.c +++ b/zebra/test_main.c @@ -308,8 +308,11 @@ main (int argc, char **argv) exit (0); /* Daemonize. */ - if (daemon_mode) - daemon (0, 0); + if (daemon_mode && daemon (0, 0) < 0) + { + perror("daemon start failed"); + exit (1); + } /* Needed for BSD routing socket. */ pid = getpid (); -- cgit v1.2.1