From 065de90380c88d9fcc116627f714bed9984c2723 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <shemminger@vyatta.com>
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.
---
 watchquagga/watchquagga.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'watchquagga')

diff --git a/watchquagga/watchquagga.c b/watchquagga/watchquagga.c
index f4c483cf..fb628acc 100644
--- a/watchquagga/watchquagga.c
+++ b/watchquagga/watchquagga.c
@@ -1343,7 +1343,11 @@ main(int argc, char **argv)
   if (daemon_mode)
     {
       zlog_set_level(NULL, ZLOG_DEST_SYSLOG, MIN(gs.loglevel,LOG_DEBUG));
-      daemon(0, 0);
+      if (daemon (0, 0) < 0)
+	{
+	  fprintf(stderr, "Watchquagga daemon failed: %s", strerror(errno));
+	  exit (1);
+	}
     }
   else
     zlog_set_level(NULL, ZLOG_DEST_STDOUT, MIN(gs.loglevel,LOG_DEBUG));
-- 
cgit v1.2.1