#include <sys/types.h>
#include <stdio.h>
+#include <errno.h>
#include "loc_incl.h"
ssize_t _write(int d, const char *buf, size_t nbytes);
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;
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);
}
if ( fstat( fd, &st ) == 0 ) {
- if ( st.st_mode & S_IFIFO ) flags |= _IOFIFO;
+ if ( S_ISFIFO(st.st_mode) ) flags |= _IOFIFO;
} else {
goto loser;
}