[Olsr-dev] [PATCH v1 08/23] unix: call olsr_exit() instead of exit()

Ferry Huberts (spam-protected)
Fri Nov 6 16:29:00 CET 2015

From: Ferry Huberts <(spam-protected)>

olsr_exit tries to do proper shutdown that cleans up data structures
by raise()ing the SIGTERM signal. This signal then causes olsr_shutdown
to be invoked (only when the signal handler is setup), which will do
the cleanup of the data structures.

According to the man page of raise():
  If the signal causes a handler to be called, raise() will return
  only after the signal handler has returned.

And since olsr_exit() invokes exit() after raise()ing the signal, there
is no harm in calling it.

Signed-off-by: Ferry Huberts <(spam-protected)>
 src/unix/ifnet.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/unix/ifnet.c b/src/unix/ifnet.c
index 7fc7367..ef1c582 100644
--- a/src/unix/ifnet.c
+++ b/src/unix/ifnet.c
@@ -452,13 +452,7 @@ add_hemu_if(struct olsr_if *iface)
     ifp->olsr_socket = gethemusocket(&sin);
     if (ifp->olsr_socket < 0) {
-      fprintf(stderr, "Could not initialize socket... exiting!\n\n");
-      olsr_syslog(OLSR_LOG_ERR, "Could not initialize socket... exiting!\n\n");
-      olsr_cnf->exit_value = EXIT_FAILURE;
-      kill(getpid(), SIGINT);
-      /* the kill command should not come back, just to be sure */
-      exit(1);
+      olsr_exit("Could not initialize socket", EXIT_FAILURE);
   } else {

More information about the Olsr-dev mailing list