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

Ferry Huberts (spam-protected)
Fri Nov 6 16:28:57 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)>
 lib/pgraph/src/olsrd_pgraph.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/pgraph/src/olsrd_pgraph.c b/lib/pgraph/src/olsrd_pgraph.c
index f3b194c..acd9d72 100644
--- a/lib/pgraph/src/olsrd_pgraph.c
+++ b/lib/pgraph/src/olsrd_pgraph.c
@@ -55,6 +55,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
+#include <signal.h>
 #ifdef _WIN32
 #define close(x) closesocket(x)
 #endif /* _WIN32 */
@@ -271,8 +272,9 @@ ipc_action(int fd __attribute__ ((unused)), void *data __attribute__ ((unused)),
   addrlen = sizeof(struct sockaddr_in);
   if ((ipc_connection = accept(ipc_socket, (struct sockaddr *)&pin, &addrlen)) == -1) {
-    olsr_printf(1, "(DOT DRAW)IPC accept: %s\n", strerror(errno));
-    exit(1);
+    char buf2[1024];
+    snprintf(buf2, sizeof(buf2), "(DOT DRAW)IPC accept error: %s", strerror(errno));
+    olsr_exit(buf2, 1);
   } else {
     struct ipaddr_str main_addr;
     addr = inet_ntoa(pin.sin_addr);

More information about the Olsr-dev mailing list