summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2009-08-07 11:13:49 -0700
committerPaul Jakma <paul@quagga.net>2009-08-13 10:21:13 +0100
commit065de90380c88d9fcc116627f714bed9984c2723 (patch)
tree79061a2699e0dc3e87c218b3b57c2f0577d5a69a
parent5bd5881838c22e075c3d0c245a8952a55e9dca38 (diff)
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.
-rw-r--r--isisd/isis_main.c7
-rw-r--r--ospf6d/ospf6_main.c7
-rw-r--r--ospfd/ospf_main.c7
-rw-r--r--ripd/rip_main.c7
-rw-r--r--ripngd/ripng_main.c7
-rw-r--r--tests/main.c7
-rw-r--r--watchquagga/watchquagga.c6
-rw-r--r--zebra/main.c7
-rw-r--r--zebra/test_main.c7
9 files changed, 45 insertions, 17 deletions
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index 2411518d..c5e824c1 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -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);
diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c
index 73d9150e..a7a96a1f 100644
--- a/ospf6d/ospf6_main.c
+++ b/ospf6d/ospf6_main.c
@@ -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);
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 2dd997e8..8b9a3458 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -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);
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index 0b29107d..57b5f3af 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -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);
diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c
index f174610d..85209a15 100644
--- a/ripngd/ripng_main.c
+++ b/ripngd/ripng_main.c
@@ -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);
diff --git a/tests/main.c b/tests/main.c
index edc3b2de..e0fbb4d5 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -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");
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));
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 ();