aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstddjb/open2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/open2.c')
-rw-r--r--src/libstddjb/open2.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstddjb/open2.c b/src/libstddjb/open2.c
index 0f23183..cf3e740 100644
--- a/src/libstddjb/open2.c
+++ b/src/libstddjb/open2.c
@@ -13,9 +13,11 @@
int open2 (char const *s, unsigned int flags)
{
+ int e = errno ;
int r ;
do r = open(s, flags) ;
while (r == -1 && errno == EINTR) ;
+ if (r >= 0) errno = e ;
return r ;
}
@@ -23,6 +25,7 @@ int open2 (char const *s, unsigned int flags)
int open2 (char const *s, unsigned int flags)
{
+ int e = errno ;
int fd ;
do fd = open(s, flags & ~O_CLOEXEC) ;
while (fd == -1 && errno == EINTR) ;
@@ -32,6 +35,7 @@ int open2 (char const *s, unsigned int flags)
fd_close(fd) ;
return -1 ;
}
+ errno = e ;
return fd ;
}