aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.h1
-rw-r--r--lib/xwrap.c2
2 files changed, 3 insertions, 0 deletions
diff --git a/lib/lib.h b/lib/lib.h
index 3c5adb43..647f5328 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -142,6 +142,7 @@ int xopenro(char *path);
void xpipe(int *pp);
void xclose(int fd);
int xdup(int fd);
+int notstdio(int fd);
FILE *xfdopen(int fd, char *mode);
FILE *xfopen(char *path, char *mode);
size_t xread(int fd, void *buf, size_t len);
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 89488acf..66972f2b 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -357,6 +357,8 @@ int xdup(int fd)
// old one. (We should never be called with stdin/stdout/stderr closed, but...)
int notstdio(int fd)
{
+ if (fd<0) return fd;
+
while (fd<3) {
int fd2 = xdup(fd);