From c1dd73319e5bc80a158cb1c4cffae3c9a7b13a87 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Thu, 26 May 2016 14:42:45 +0200 Subject: ipcpd: Cleanup handler for main message loop This adds a cleanup handler for the main message loop, which closes the socket upon pthread_cancel so that the ipcp can exit cleanly. --- src/ipcpd/ipcp.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/ipcpd/ipcp.c') diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index dd370005..e0dd1b60 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -93,6 +93,9 @@ void * ipcp_main_loop(void * o) return (void *) 1; } + pthread_cleanup_push((void(*)(void *)) close, + (void *) &sockfd); + free(sock_path); while (true) { @@ -259,5 +262,7 @@ void * ipcp_main_loop(void * o) close(lsockfd); } + pthread_cleanup_pop(0); + return NULL; } -- cgit v1.2.3