Skip to content

Commit caceec3

Browse files
committed
fix scp client hanging with pipes
1 parent 718aab1 commit caceec3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

scp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ do_cmd(char *program, char *host, char *remuser, int port, int subsystem,
344344
#ifdef USE_PIPES
345345
if (pipe(pin) == -1 || pipe(pout) == -1)
346346
fatal("pipe: %s", strerror(errno));
347+
fcntl(pout[0], F_SETFD, FD_CLOEXEC);
348+
fcntl(pout[1], F_SETFD, FD_CLOEXEC);
349+
fcntl(pin[0], F_SETFD, FD_CLOEXEC);
350+
fcntl(pin[1], F_SETFD, FD_CLOEXEC);
347351
#else
348352
/* Create a socket pair for communicating with ssh. */
349353
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1)

0 commit comments

Comments
 (0)