summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/serverloop.c
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>1999-10-04 21:54:40 +0000
committermarkus <markus@openbsd.org>1999-10-04 21:54:40 +0000
commitfa5f6d14c7e56f53623fef0cba8fe7f2402a276f (patch)
tree4ddf8d9ee906cfa4b4b8eaa6208ea58de98930fd /usr.bin/ssh/serverloop.c
parentSynch with current development: (diff)
downloadwireguard-openbsd-fa5f6d14c7e56f53623fef0cba8fe7f2402a276f.tar.xz
wireguard-openbsd-fa5f6d14c7e56f53623fef0cba8fe7f2402a276f.zip
fix shutdown() for sockets, the last one has to close the socket
Diffstat (limited to 'usr.bin/ssh/serverloop.c')
-rw-r--r--usr.bin/ssh/serverloop.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/usr.bin/ssh/serverloop.c b/usr.bin/ssh/serverloop.c
index 0545b04747d..552c69c2952 100644
--- a/usr.bin/ssh/serverloop.c
+++ b/usr.bin/ssh/serverloop.c
@@ -362,7 +362,10 @@ void process_output(fd_set *writeset)
#ifdef USE_PIPES
close(fdin);
#else
- shutdown(fdin, SHUT_WR); /* We will no longer send. */
+ if (fdout == -1)
+ close(fdin);
+ else
+ shutdown(fdin, SHUT_WR); /* We will no longer send. */
#endif
fdin = -1;
}
@@ -486,7 +489,10 @@ void server_loop(int pid, int fdin_arg, int fdout_arg, int fderr_arg)
#ifdef USE_PIPES
close(fdin);
#else
- shutdown(fdin, SHUT_WR); /* We will no longer send. */
+ if (fdout == -1)
+ close(fdin);
+ else
+ shutdown(fdin, SHUT_WR); /* We will no longer send. */
#endif
fdin = -1;
}
@@ -565,27 +571,15 @@ void server_loop(int pid, int fdin_arg, int fdout_arg, int fderr_arg)
/* Close the file descriptors. */
if (fdout != -1)
-#ifdef USE_PIPES
close(fdout);
-#else
- shutdown(fdout, SHUT_RD);
-#endif
fdout = -1;
fdout_eof = 1;
if (fderr != -1)
-#ifdef USE_PIPES
close(fderr);
-#else
- shutdown(fderr, SHUT_RD);
-#endif
fderr = -1;
fderr_eof = 1;
if (fdin != -1)
-#ifdef USE_PIPES
close(fdin);
-#else
- shutdown(fdin, SHUT_WR);
-#endif
fdin = -1;
/* Stop listening for channels; this removes unix domain sockets. */