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)
- 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 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