summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/clientloop.c b/clientloop.c
index b2b7debc8..ba957fe47 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.69 2001/05/08 19:17:31 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.70 2001/05/11 14:59:55 markus Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -935,22 +935,35 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
935 snprintf(buf, sizeof buf, "Connection to %.64s closed.\r\n", host); 935 snprintf(buf, sizeof buf, "Connection to %.64s closed.\r\n", host);
936 buffer_append(&stderr_buffer, buf, strlen(buf)); 936 buffer_append(&stderr_buffer, buf, strlen(buf));
937 } 937 }
938
939 /* restore blocking io */
940 if (!isatty(fileno(stdin)))
941 unset_nonblock(fileno(stdin));
942 if (!isatty(fileno(stdout)))
943 unset_nonblock(fileno(stdout));
944 if (!isatty(fileno(stderr)))
945 unset_nonblock(fileno(stderr));
946
938 /* Output any buffered data for stdout. */ 947 /* Output any buffered data for stdout. */
939 if (buffer_len(&stdout_buffer) > 0) { 948 while (buffer_len(&stdout_buffer) > 0) {
940 len = atomicio(write, fileno(stdout), buffer_ptr(&stdout_buffer), 949 len = write(fileno(stdout), buffer_ptr(&stdout_buffer),
941 buffer_len(&stdout_buffer)); 950 buffer_len(&stdout_buffer));
942 if (len != buffer_len(&stdout_buffer)) 951 if (len <= 0) {
943 error("Write failed flushing stdout buffer."); 952 error("Write failed flushing stdout buffer.");
953 break;
954 }
944 buffer_consume(&stdout_buffer, len); 955 buffer_consume(&stdout_buffer, len);
945 stdout_bytes += len; 956 stdout_bytes += len;
946 } 957 }
947 958
948 /* Output any buffered data for stderr. */ 959 /* Output any buffered data for stderr. */
949 if (buffer_len(&stderr_buffer) > 0) { 960 while (buffer_len(&stderr_buffer) > 0) {
950 len = atomicio(write, fileno(stderr), buffer_ptr(&stderr_buffer), 961 len = write(fileno(stderr), buffer_ptr(&stderr_buffer),
951 buffer_len(&stderr_buffer)); 962 buffer_len(&stderr_buffer));
952 if (len != buffer_len(&stderr_buffer)) 963 if (len <= 0) {
953 error("Write failed flushing stderr buffer."); 964 error("Write failed flushing stderr buffer.");
965 break;
966 }
954 buffer_consume(&stderr_buffer, len); 967 buffer_consume(&stderr_buffer, len);
955 stderr_bytes += len; 968 stderr_bytes += len;
956 } 969 }