diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-12 00:08:37 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-12 00:08:37 +0000 |
commit | c93e84c2cecf2b968a069de595aff374abe89036 (patch) | |
tree | a2fd75f89b96705ccfd0cd8f85a9db5e582c2fca /misc.c | |
parent | ddb4f24056225322bc97eb366cbe5b2927fd7c89 (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.c | 29 |
1 files changed, 26 insertions, 3 deletions
@@ -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" |
28 | RCSID("$OpenBSD: misc.c,v 1.7 2001/05/08 19:45:24 mouring Exp $"); | 28 | RCSID("$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 | |||
50 | set_nonblock(int fd) | 50 | set_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 | ||
71 | void | ||
72 | unset_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 | ||