summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-05-08 23:58:37 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-05-08 23:58:37 +0000
commit23fedf5e493b1347e6923a8ea54c941fe10fb208 (patch)
tree4355d6548756e97017f51cf52634ee925b12e5c7 /clientloop.c
parent72af2ef8db31b13b8b51a2a29ed8edf36f3c89fb (diff)
- markus@cvs.openbsd.org 2001/05/06 21:45:14
[clientloop.c] use atomicio for flushing stdout/stderr bufs. thanks to jbw@izanami.cee.hw.ac.uk
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/clientloop.c b/clientloop.c
index 2bc5b54a..3294b0cf 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: clientloop.c,v 1.67 2001/05/04 23:47:34 markus Exp $");
+RCSID("$OpenBSD: clientloop.c,v 1.68 2001/05/06 21:45:14 markus Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -936,25 +936,21 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
buffer_append(&stderr_buffer, buf, strlen(buf));
}
/* Output any buffered data for stdout. */
- while (buffer_len(&stdout_buffer) > 0) {
- len = write(fileno(stdout), buffer_ptr(&stdout_buffer),
+ if (buffer_len(&stdout_buffer) > 0) {
+ len = atomicio(write, fileno(stdout), buffer_ptr(&stdout_buffer),
buffer_len(&stdout_buffer));
- if (len <= 0) {
+ if (len != buffer_len(&stdout_buffer))
error("Write failed flushing stdout buffer.");
- break;
- }
buffer_consume(&stdout_buffer, len);
stdout_bytes += len;
}
/* Output any buffered data for stderr. */
- while (buffer_len(&stderr_buffer) > 0) {
- len = write(fileno(stderr), buffer_ptr(&stderr_buffer),
+ if (buffer_len(&stderr_buffer) > 0) {
+ len = atomicio(write, fileno(stderr), buffer_ptr(&stderr_buffer),
buffer_len(&stderr_buffer));
- if (len <= 0) {
+ if (len != buffer_len(&stderr_buffer))
error("Write failed flushing stderr buffer.");
- break;
- }
buffer_consume(&stderr_buffer, len);
stderr_bytes += len;
}