From caceec39ab395edbb4b291c93501a83990b26c03 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Fri, 3 Feb 2023 14:24:21 -0500 Subject: [PATCH] fix scp client hanging with pipes --- scp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scp.c b/scp.c index 3ce820167..ba3339069 100644 --- a/scp.c +++ b/scp.c @@ -344,6 +344,10 @@ do_cmd(char *program, char *host, char *remuser, int port, int subsystem, #ifdef USE_PIPES if (pipe(pin) == -1 || pipe(pout) == -1) fatal("pipe: %s", strerror(errno)); + fcntl(pout[0], F_SETFD, FD_CLOEXEC); + fcntl(pout[1], F_SETFD, FD_CLOEXEC); + fcntl(pin[0], F_SETFD, FD_CLOEXEC); + fcntl(pin[1], F_SETFD, FD_CLOEXEC); #else /* Create a socket pair for communicating with ssh. */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1)