From d120d8bb97d6315eec3c68f2feeb42adddc01b43 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Thu, 1 Jul 2021 17:03:13 +0100 Subject: [PATCH] Clear epoll_fd after forking to background self Otherwise we remove the events from the epoll_fd before we exit in the parent process. This would be a bit awful if it were something we require all users of libopenconnect to know about, but it isn't. We make everything O_CLOEXEC and we don't expect users to be calling openconnect_vpninfo_free() from another process after forking, like the background code does. We only do it there so that we can check for memory leaks (I think). Signed-off-by: David Woodhouse --- main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.c b/main.c index 1a4455a8..c6908eb9 100644 --- a/main.c +++ b/main.c @@ -1544,6 +1544,8 @@ static int background_self(struct openconnect_info *vpninfo, char *pidfile) _("Continuing in background; pid %d\n"), pid); sig_vpninfo = NULL; + /* Don't invoke EPOLL_CTL_DEL; it'll mess up the real one */ + vpninfo->epoll_fd = -1; openconnect_vpninfo_free(vpninfo); exit(0); } -- 2.50.1