From: David Woodhouse Date: Thu, 1 Jul 2021 16:03:13 +0000 (+0100) Subject: Clear epoll_fd after forking to background self X-Git-Tag: v8.20~108 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d120d8bb97d6315eec3c68f2feeb42adddc01b43;p=users%2Fdwmw2%2Fopenconnect.git 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 --- 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); }