From aa162bbca1bda79b9e100a60c09af04a70f223f5 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 21 Oct 2018 10:14:22 +0100 Subject: [PATCH] Close standard handles in watchdog subprocesses. Naturally, there's one really glaring goof I find out instants after 'git push'! If Pageant starts a watchdog subprocess which will wait until the main process terminates and then clean up the socket, then it had better not have that subprocess keep the standard I/O handles open, or else commands like eval $(pageant -X) won't terminate. I've applied the same fix in the X11 socket creation, though I think it's less critical there. --- unix/ux_x11.c | 5 +++++ unix/uxagentsock.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/unix/ux_x11.c b/unix/ux_x11.c index 91c95bbc..4df66d15 100644 --- a/unix/ux_x11.c +++ b/unix/ux_x11.c @@ -159,6 +159,11 @@ int platform_make_x11_server(Plug *plug, const char *progname, int mindisp, * we expect read() to return EOF as soon as * that process terminates. */ + + close(0); + close(1); + close(2); + setpgid(0, 0); close(cleanup_pipe[1]); close(authfd); diff --git a/unix/uxagentsock.c b/unix/uxagentsock.c index 90e701ff..3fbbb84f 100644 --- a/unix/uxagentsock.c +++ b/unix/uxagentsock.c @@ -62,6 +62,11 @@ Socket *platform_make_agent_socket( * we expect read() to return EOF as soon as * that process terminates. */ + + close(0); + close(1); + close(2); + setpgid(0, 0); close(cleanup_pipe[1]); while (read(cleanup_pipe[0], buf, sizeof(buf)) > 0);