Fix lseek changing errno in fdio_install_fd when no real error occurs.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-02-15 20:57:49 +01:00
parent fd5b40de26
commit 31c310036c
1 changed files with 2 additions and 0 deletions

View File

@ -207,8 +207,10 @@ extern "C" int fdio_install_fd(FILE* fp, int fd, const char* mode)
fp->error_func = fdio_error;
fp->fileno_func = fdio_fileno;
fp->close_func = fdio_close;
int preserved_errno = errno;
if ( lseek(fd, 0, SEEK_CUR) < 0 && errno == ESPIPE )
fp->flags |= _FILE_STREAM;
errno = preserved_errno;
return 1;
}