changeset 8392:ac5d6be5a627

Preserve errno.
author Bruno Haible <bruno@clisp.org>
date Fri, 09 Mar 2007 02:41:51 +0000
parents e867946a9882
children 744a1a36452c
files lib/fseterr.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/fseterr.c
+++ b/lib/fseterr.c
@@ -20,6 +20,8 @@
 /* Specification.  */
 #include "fseterr.h"
 
+#include <errno.h>
+
 void
 fseterr (FILE *fp)
 {
@@ -35,9 +37,11 @@
 #else                               /* unknown  */
   /* Portable fallback, based on an idea by Rich Felker.
      Wow! 6 system calls for something that is just a bit operation!  */
+  int saved_errno;
   int fd;
   int fd2;
 
+  saved_errno = errno;
   fflush (fp);
   fd = fileno (fp);
   fd2 = dup (fd);
@@ -51,5 +55,6 @@
 	abort ();
       close (fd2);
     }
+  errno = saved_errno;
 #endif
 }