summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--clientloop.c27
-rw-r--r--defines.h4
-rw-r--r--misc.c29
-rw-r--r--misc.h5
5 files changed, 58 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 7fe389325..3833f3036 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
120010512
2 - OpenBSD CVS Sync
3 - markus@cvs.openbsd.org 2001/05/11 14:59:56
4 [clientloop.c misc.c misc.h]
5 add unset_nonblock for stdout/err flushing in client_loop().
6
120010511 720010511
2 - OpenBSD CVS Sync 8 - OpenBSD CVS Sync
3 - markus@cvs.openbsd.org 2001/05/09 22:51:57 9 - markus@cvs.openbsd.org 2001/05/09 22:51:57
@@ -5394,4 +5400,4 @@
5394 - Wrote replacements for strlcpy and mkdtemp 5400 - Wrote replacements for strlcpy and mkdtemp
5395 - Released 1.0pre1 5401 - Released 1.0pre1
5396 5402
5397$Id: ChangeLog,v 1.1216 2001/05/10 23:26:11 mouring Exp $ 5403$Id: ChangeLog,v 1.1217 2001/05/12 00:08:37 mouring Exp $
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 }
diff --git a/defines.h b/defines.h
index ebe8812ae..347aad5a5 100644
--- a/defines.h
+++ b/defines.h
@@ -1,7 +1,7 @@
1#ifndef _DEFINES_H 1#ifndef _DEFINES_H
2#define _DEFINES_H 2#define _DEFINES_H
3 3
4/* $Id: defines.h,v 1.63 2001/05/09 00:38:21 mouring Exp $ */ 4/* $Id: defines.h,v 1.64 2001/05/12 00:08:38 mouring Exp $ */
5 5
6/* Some platforms need this for the _r() functions */ 6/* Some platforms need this for the _r() functions */
7#if !defined(_REENTRANT) && !defined(SNI) 7#if !defined(_REENTRANT) && !defined(SNI)
@@ -418,7 +418,7 @@ struct winsize {
418#endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */ 418#endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */
419 419
420#if !defined(HAVE_ATEXIT) && defined(HAVE_ON_EXIT) 420#if !defined(HAVE_ATEXIT) && defined(HAVE_ON_EXIT)
421# define atexit(a) on_exit(a) 421# define atexit(a) on_exit(a, NULL)
422#else 422#else
423# if defined(HAVE_XATEXIT) 423# if defined(HAVE_XATEXIT)
424# define atexit(a) xatexit(a) 424# define atexit(a) xatexit(a)
diff --git a/misc.c b/misc.c
index d12bcefe5..b0fdbe03c 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.7 2001/05/08 19:45:24 mouring Exp $ */ 1/* $OpenBSD: misc.c,v 1.8 2001/05/11 14:59:56 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: misc.c,v 1.7 2001/05/08 19:45:24 mouring Exp $"); 28RCSID("$OpenBSD: misc.c,v 1.8 2001/05/11 14:59:56 markus Exp $");
29 29
30#include "misc.h" 30#include "misc.h"
31#include "log.h" 31#include "log.h"
@@ -50,13 +50,14 @@ void
50set_nonblock(int fd) 50set_nonblock(int fd)
51{ 51{
52 int val; 52 int val;
53
53 val = fcntl(fd, F_GETFL, 0); 54 val = fcntl(fd, F_GETFL, 0);
54 if (val < 0) { 55 if (val < 0) {
55 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno)); 56 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
56 return; 57 return;
57 } 58 }
58 if (val & O_NONBLOCK) { 59 if (val & O_NONBLOCK) {
59 debug("fd %d IS O_NONBLOCK", fd); 60 debug2("fd %d is O_NONBLOCK", fd);
60 return; 61 return;
61 } 62 }
62 debug("fd %d setting O_NONBLOCK", fd); 63 debug("fd %d setting O_NONBLOCK", fd);
@@ -67,6 +68,28 @@ set_nonblock(int fd)
67 fd, strerror(errno)); 68 fd, strerror(errno));
68} 69}
69 70
71void
72unset_nonblock(int fd)
73{
74 int val;
75
76 val = fcntl(fd, F_GETFL, 0);
77 if (val < 0) {
78 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
79 return;
80 }
81 if (!(val & O_NONBLOCK)) {
82 debug2("fd %d is not O_NONBLOCK", fd);
83 return;
84 }
85 debug("fd %d setting O_NONBLOCK", fd);
86 val &= ~O_NONBLOCK;
87 if (fcntl(fd, F_SETFL, val) == -1)
88 if (errno != ENODEV)
89 error("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
90 fd, strerror(errno));
91}
92
70/* Characters considered whitespace in strsep calls. */ 93/* Characters considered whitespace in strsep calls. */
71#define WHITESPACE " \t\r\n" 94#define WHITESPACE " \t\r\n"
72 95
diff --git a/misc.h b/misc.h
index b30fe4884..01a736c03 100644
--- a/misc.h
+++ b/misc.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.h,v 1.6 2001/05/08 19:45:24 mouring Exp $ */ 1/* $OpenBSD: misc.h,v 1.7 2001/05/11 14:59:56 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -17,8 +17,9 @@ char *chop(char *s);
17/* return next token in configuration line */ 17/* return next token in configuration line */
18char *strdelim(char **s); 18char *strdelim(char **s);
19 19
20/* set filedescriptor to non-blocking */ 20/* set/unset filedescriptor to non-blocking */
21void set_nonblock(int fd); 21void set_nonblock(int fd);
22void unset_nonblock(int fd);
22 23
23struct passwd * pwcopy(struct passwd *pw); 24struct passwd * pwcopy(struct passwd *pw);
24 25