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.
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index 2411518..c5e824c 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -333,8 +333,11 @@
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 73d9150..a7a96a1 100644
--- a/ospf6d/ospf6_main.c
+++ b/ospf6d/ospf6_main.c
@@ -282,8 +282,11 @@
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 2dd997e..8b9a345 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -314,8 +314,11 @@
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 0b29107..57b5f3a 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -292,8 +292,11 @@
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 f174610..85209a1 100644
--- a/ripngd/ripng_main.c
+++ b/ripngd/ripng_main.c
@@ -288,8 +288,11 @@
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 edc3b2d..e0fbb4d 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -174,8 +174,11 @@
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 f4c483c..fb628ac 100644
--- a/watchquagga/watchquagga.c
+++ b/watchquagga/watchquagga.c
@@ -1343,7 +1343,11 @@
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 2d6a4ac..d829c04 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -362,8 +362,11 @@
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 e186fea..4398a38 100644
--- a/zebra/test_main.c
+++ b/zebra/test_main.c
@@ -308,8 +308,11 @@
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 ();