]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Clear epoll_fd after forking to background self
authorDavid Woodhouse <dwmw2@infradead.org>
Thu, 1 Jul 2021 16:03:13 +0000 (17:03 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Thu, 1 Jul 2021 16:09:38 +0000 (17:09 +0100)
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 <dwmw2@infradead.org>
main.c

diff --git a/main.c b/main.c
index 1a4455a8a1642d76043f8eb0226097280469ee10..c6908eb97ddde8d739288ece55e7e9ee662325b3 100644 (file)
--- 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);
        }