From: Ben Gras Date: Thu, 2 Feb 2006 16:59:07 +0000 (+0000) Subject: . use proper S_ISFIFO for ISFIFO check X-Git-Tag: v3.1.2a~395 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/static/style.css?a=commitdiff_plain;h=a3bda44a41c419a1904d38c0fc00b39f5ba105d3;p=minix.git . use proper S_ISFIFO for ISFIFO check . ignore ESPIPE error from lseek() in fflush() on read streams (because fifo's aren't detected when stdin, stdout or stderr) --- diff --git a/lib/stdio/fflush.c b/lib/stdio/fflush.c index ce058570d..b154609d0 100755 --- a/lib/stdio/fflush.c +++ b/lib/stdio/fflush.c @@ -5,6 +5,7 @@ #include #include +#include #include "loc_incl.h" ssize_t _write(int d, const char *buf, size_t nbytes); @@ -36,10 +37,12 @@ fflush(FILE *stream) if (stream->_buf && !io_testflag(stream,_IONBF)) adjust = -stream->_count; stream->_count = 0; - if (_lseek(fileno(stream), (off_t) adjust, SEEK_CUR) == -1) { + if (_lseek(fileno(stream), (off_t) adjust, SEEK_CUR) == -1 && + errno != ESPIPE) { stream->_flags |= _IOERR; return EOF; } + errno = 0; if (io_testflag(stream, _IOWRITE)) stream->_flags &= ~(_IOREADING | _IOWRITING); stream->_ptr = stream->_buf; diff --git a/lib/stdio/fopen.c b/lib/stdio/fopen.c index 82663f599..777cc7a01 100755 --- a/lib/stdio/fopen.c +++ b/lib/stdio/fopen.c @@ -110,7 +110,7 @@ fopen(const char *name, const char *mode) return (FILE *)NULL; } - if ( st.st_mode & S_IFIFO ) flags |= _IOFIFO; + if ( S_ISFIFO(st.st_mode) ) flags |= _IOFIFO; if (( stream = (FILE *) malloc(sizeof(FILE))) == NULL ) { _close(fd); diff --git a/lib/stdio/freopen.c b/lib/stdio/freopen.c index a81137794..20a42505e 100755 --- a/lib/stdio/freopen.c +++ b/lib/stdio/freopen.c @@ -87,7 +87,7 @@ freopen(const char *name, const char *mode, FILE *stream) } if ( fstat( fd, &st ) == 0 ) { - if ( st.st_mode & S_IFIFO ) flags |= _IOFIFO; + if ( S_ISFIFO(st.st_mode) ) flags |= _IOFIFO; } else { goto loser; }