aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstddjb/fd_copy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/fd_copy.c')
-rw-r--r--src/libstddjb/fd_copy.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstddjb/fd_copy.c b/src/libstddjb/fd_copy.c
index 80b887e..1afad1f 100644
--- a/src/libstddjb/fd_copy.c
+++ b/src/libstddjb/fd_copy.c
@@ -2,14 +2,16 @@
#include <unistd.h>
#include <errno.h>
+
#include <skalibs/djbunix.h>
int fd_copy (int to, int from)
{
+ int e = errno ;
int r ;
if (to == from) return (errno = EINVAL, -1) ;
- do
- r = dup2(from, to) ;
- while ((r == -1) && (errno == EINTR)) ;
+ do r = dup2(from, to) ;
+ while (r == -1 && errno == EINTR) ;
+ if (r >= 0) errno = e ;
return r ;
}