]> git.puffer.fish Git - mirror/frr.git/commitdiff
all: check return value from daemon() call
authorStephen Hemminger <shemminger@vyatta.com>
Fri, 7 Aug 2009 18:13:49 +0000 (11:13 -0700)
committerPaul Jakma <paul@quagga.net>
Thu, 13 Aug 2009 09:21:13 +0000 (10:21 +0100)
* */*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.

isisd/isis_main.c
ospf6d/ospf6_main.c
ospfd/ospf_main.c
ripd/rip_main.c
ripngd/ripng_main.c
tests/main.c
watchquagga/watchquagga.c
zebra/main.c
zebra/test_main.c

index 2411518d82e40e704835a13f686953b961466716..c5e824c192f5fe2548e88880e9566332c1a0318a 100644 (file)
@@ -333,8 +333,11 @@ main (int argc, char **argv, char **envp)
     return(0);
   
   /* demonize */
-  if (daemon_mode)
-    daemon (0, 0);
+  if (daemon_mode && daemon (0, 0) < 0)
+    {
+      zlog_err("ISISd daemon failed: %s", strerror(errno));
+      exit (1);
+    }
 
   /* Process ID file creation. */
   pid_output (pid_file);
index 73d9150e8d65bf34e2199de16a92e46e1bc21ddd..a7a96a1f0e08ba50b860da31996a49aa52a24552 100644 (file)
@@ -282,8 +282,11 @@ main (int argc, char *argv[], char *envp[])
   if (dryrun)
     return(0);
   
-  if (daemon_mode)
-    daemon (0, 0);
+  if (daemon_mode && daemon (0, 0) < 0)
+    {
+      zlog_err("OSPF6d daemon failed: %s", strerror(errno));
+      exit (1);
+    }
 
   /* pid file create */
   pid_output (pid_file);
index 2dd997e876249a19844757e45c43435790e72316..8b9a3458db4edd33178ea518f580b5447afc7f62 100644 (file)
@@ -314,8 +314,11 @@ main (int argc, char **argv)
     return(0);
   
   /* Change to the daemon program. */
-  if (daemon_mode)
-    daemon (0, 0);
+  if (daemon_mode && daemon (0, 0) < 0)
+    {
+      zlog_err("OSPFd daemon failed: %s", strerror(errno));
+      exit (1);
+    }
 
   /* Process id file create. */
   pid_output (pid_file);
index 0b29107d30119887982d4b2d00584d792ceed492..57b5f3af2ae6838c9830e90cb7d4f35c0c2e0bd4 100644 (file)
@@ -292,8 +292,11 @@ main (int argc, char **argv)
     return (0);
   
   /* Change to the daemon program. */
-  if (daemon_mode)
-    daemon (0, 0);
+  if (daemon_mode && daemon (0, 0) < 0)
+    {
+      zlog_err("RIPd daemon failed: %s", strerror(errno));
+      exit (1);
+    }
 
   /* Pid file create. */
   pid_output (pid_file);
index f174610d113fa4e6aa6c9f2ec769b305ea257a74..85209a15842432085cf79296d545f8458dac991a 100644 (file)
@@ -288,8 +288,11 @@ main (int argc, char **argv)
     return(0);
   
   /* Change to the daemon program. */
-  if (daemon_mode)
-    daemon (0, 0);
+  if (daemon_mode && daemon (0, 0) < 0)
+    {
+      zlog_err("RIPNGd daemon failed: %s", strerror(errno));
+      exit (1);
+    }
 
   /* Create VTY socket */
   vty_serv_sock (vty_addr, vty_port, RIPNG_VTYSH_PATH);
index edc3b2de9cecd50fd9358735c283fbcb0f7ef596..e0fbb4d51530b786aabb39a88a0a5c2c741ee016 100644 (file)
@@ -174,8 +174,11 @@ main (int argc, char **argv)
   sort_node ();
 
   /* Change to the daemon program. */
-  if (daemon_mode)
-    daemon (0, 0);
+  if (daemon_mode && daemon (0, 0) < 0)
+    {
+      fprintf(stderr, "daemon failed: %s", strerror(errno));
+      exit (1);
+    }
 
   /* Create VTY socket */
   vty_serv_sock (vty_addr, vty_port, "/tmp/.heavy.sock");
index f4c483cf428a9719eadac46b933b698abd4f4b9d..fb628acca31640a1df139fe8d8aff9e6bd2778f4 100644 (file)
@@ -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));
index 2d6a4ac865fb9a553c2401670036ae8bc186baa8..d829c046c6e5a780f73cab5b8cd528995546b3e3 100644 (file)
@@ -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);
index e186fea614922c97b8b2b3ddad07c952a57d7f09..4398a389d480ecb369c39d721ded6da05a695060 100644 (file)
@@ -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 ();