From: Jarkko Hietaniemi Date: Wed, 26 Jan 2000 13:58:18 +0000 (+0000) Subject: In UNICOS and UNICOS/mk after a successful fcntl F_SETFL X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6fd254a478c7f8019c24fcc4c32de680d740e450;p=p5sagit%2Fp5-mst-13.2.git In UNICOS and UNICOS/mk after a successful fcntl F_SETFL of O_NONBLOCK a subsequent fcntl F_GETFL will return O_NDELAY. p4raw-id: //depot/cfgperl@4904 --- diff --git a/ext/IO/IO.xs b/ext/IO/IO.xs index e5ce83d..be84f73 100644 --- a/ext/IO/IO.xs +++ b/ext/IO/IO.xs @@ -62,23 +62,28 @@ io_blocking(InputStream f, int block) /* POSIX style */ #if defined(O_NDELAY) && O_NDELAY != O_NONBLOCK /* Ooops has O_NDELAY too - make sure we don't - * get SysV behaviour by mistake - */ - RETVAL = RETVAL & O_NONBLOCK ? 0 : 1; - - if ((mode & O_NDELAY) || ((block == 0) && !(mode & O_NONBLOCK))) { - int ret; - mode = (mode & ~O_NDELAY) | O_NONBLOCK; - ret = fcntl(PerlIO_fileno(f),F_SETFL,mode); - if(ret < 0) - RETVAL = ret; - } - else if ((mode & O_NDELAY) || ((block > 0) && (mode & O_NONBLOCK))) { - int ret; - mode &= ~(O_NONBLOCK | O_NDELAY); - ret = fcntl(PerlIO_fileno(f),F_SETFL,mode); - if(ret < 0) - RETVAL = ret; + * get SysV behaviour by mistake. */ + + /* E.g. In UNICOS and UNICOS/mk a F_GETFL returns an O_NDELAY + * after a successful F_SETFL of an O_NONBLOCK. */ + RETVAL = RETVAL & (O_NONBLOCK | O_NDELAY) ? 0 : 1; + + if (block >= 0) { + if ((mode & O_NDELAY) || ((block == 0) && !(mode & O_NONBLOCK))) { + int ret; + mode = (mode & ~O_NDELAY) | O_NONBLOCK; + ret = fcntl(PerlIO_fileno(f),F_SETFL,mode); + if(ret < 0) + RETVAL = ret; + } + else + if ((mode & O_NDELAY) || ((block > 0) && (mode & O_NONBLOCK))) { + int ret; + mode &= ~(O_NONBLOCK | O_NDELAY); + ret = fcntl(PerlIO_fileno(f),F_SETFL,mode); + if(ret < 0) + RETVAL = ret; + } } #else /* Standard POSIX */