diff options
author | jenglish <jenglish@flightlab.com> | 2008-02-28 20:12:09 (GMT) |
---|---|---|
committer | jenglish <jenglish@flightlab.com> | 2008-02-28 20:12:09 (GMT) |
commit | 6e9187684c687eab654ee37f1d4a9aa9caff97a2 (patch) | |
tree | aa41a586696a80054db4e5e47d019b5e80c80923 /unix/tclUnixPipe.c | |
parent | 2b7f76a785b725b2cf77ee239b28c5529e92093f (diff) | |
download | tcl-6e9187684c687eab654ee37f1d4a9aa9caff97a2.zip tcl-6e9187684c687eab654ee37f1d4a9aa9caff97a2.tar.gz tcl-6e9187684c687eab654ee37f1d4a9aa9caff97a2.tar.bz2 |
Consolidate all code conditionalized on -DUSE_FIONBIO into one place.
New routine TclUnixSetBlockingMode().
Diffstat (limited to 'unix/tclUnixPipe.c')
-rw-r--r-- | unix/tclUnixPipe.c | 51 |
1 files changed, 4 insertions, 47 deletions
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index cd7a0f2..ab468b8 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPipe.c,v 1.40 2007/12/13 15:28:42 dgp Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.41 2008/02/28 20:12:09 jenglish Exp $ */ #include "tclInt.h" @@ -841,61 +841,18 @@ PipeBlockModeProc( * TCL_MODE_BLOCKING or * TCL_MODE_NONBLOCKING. */ { - PipeState *psPtr = (PipeState *) instanceData; - int curStatus; - int fd; + PipeState *psPtr = instanceData; -#ifndef USE_FIONBIO if (psPtr->inFile) { - fd = GetFd(psPtr->inFile); - curStatus = fcntl(fd, F_GETFL); - if (mode == TCL_MODE_BLOCKING) { - curStatus &= (~(O_NONBLOCK)); - } else { - curStatus |= O_NONBLOCK; - } - if (fcntl(fd, F_SETFL, curStatus) < 0) { + if (TclUnixSetBlockingMode(GetFd(psPtr->inFile), mode) < 0) { return errno; } } if (psPtr->outFile) { - fd = GetFd(psPtr->outFile); - curStatus = fcntl(fd, F_GETFL); - if (mode == TCL_MODE_BLOCKING) { - curStatus &= (~(O_NONBLOCK)); - } else { - curStatus |= O_NONBLOCK; - } - if (fcntl(fd, F_SETFL, curStatus) < 0) { - return errno; - } - } -#endif /* !FIONBIO */ - -#ifdef USE_FIONBIO - if (psPtr->inFile) { - fd = GetFd(psPtr->inFile); - if (mode == TCL_MODE_BLOCKING) { - curStatus = 0; - } else { - curStatus = 1; - } - if (ioctl(fd, (int) FIONBIO, &curStatus) < 0) { - return errno; - } - } - if (psPtr->outFile != NULL) { - fd = GetFd(psPtr->outFile); - if (mode == TCL_MODE_BLOCKING) { - curStatus = 0; - } else { - curStatus = 1; - } - if (ioctl(fd, (int) FIONBIO, &curStatus) < 0) { + if (TclUnixSetBlockingMode(GetFd(psPtr->outFile), mode) < 0) { return errno; } } -#endif /* USE_FIONBIO */ psPtr->isNonBlocking = (mode == TCL_MODE_NONBLOCKING); |