From 31c310036c0045017d158b0d542710bab46928c6 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 15 Feb 2014 20:57:49 +0100 Subject: [PATCH] Fix lseek changing errno in fdio_install_fd when no real error occurs. --- libc/stdio/fdio.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc/stdio/fdio.cpp b/libc/stdio/fdio.cpp index 3488790e..81f8f798 100644 --- a/libc/stdio/fdio.cpp +++ b/libc/stdio/fdio.cpp @@ -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; }