summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-05-12 00:08:37 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-05-12 00:08:37 +0000
commitc93e84c2cecf2b968a069de595aff374abe89036 (patch)
treea2fd75f89b96705ccfd0cd8f85a9db5e582c2fca /misc.c
parentddb4f24056225322bc97eb366cbe5b2927fd7c89 (diff)
downloadopenssh-git-c93e84c2cecf2b968a069de595aff374abe89036.tar.gz
- markus@cvs.openbsd.org 2001/05/11 14:59:56
[clientloop.c misc.c misc.h] add unset_nonblock for stdout/err flushing in client_loop().
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/misc.c b/misc.c
index d12bcefe..b0fdbe03 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.7 2001/05/08 19:45:24 mouring Exp $ */
+/* $OpenBSD: misc.c,v 1.8 2001/05/11 14:59:56 markus Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -25,7 +25,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.7 2001/05/08 19:45:24 mouring Exp $");
+RCSID("$OpenBSD: misc.c,v 1.8 2001/05/11 14:59:56 markus Exp $");
#include "misc.h"
#include "log.h"
@@ -50,13 +50,14 @@ void
set_nonblock(int fd)
{
int val;
+
val = fcntl(fd, F_GETFL, 0);
if (val < 0) {
error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
return;
}
if (val & O_NONBLOCK) {
- debug("fd %d IS O_NONBLOCK", fd);
+ debug2("fd %d is O_NONBLOCK", fd);
return;
}
debug("fd %d setting O_NONBLOCK", fd);
@@ -67,6 +68,28 @@ set_nonblock(int fd)
fd, strerror(errno));
}
+void
+unset_nonblock(int fd)
+{
+ int val;
+
+ val = fcntl(fd, F_GETFL, 0);
+ if (val < 0) {
+ error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
+ return;
+ }
+ if (!(val & O_NONBLOCK)) {
+ debug2("fd %d is not O_NONBLOCK", fd);
+ return;
+ }
+ debug("fd %d setting O_NONBLOCK", fd);
+ val &= ~O_NONBLOCK;
+ if (fcntl(fd, F_SETFL, val) == -1)
+ if (errno != ENODEV)
+ error("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
+ fd, strerror(errno));
+}
+
/* Characters considered whitespace in strsep calls. */
#define WHITESPACE " \t\r\n"