summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-07-24 21:20:12 -0400
committerTavian Barnes <tavianator@tavianator.com>2018-07-24 21:20:12 -0400
commit2aceb02c680b689e7cecb07573347418f2dd03be (patch)
tree720ad0b7f4d095378a2b115a5633a6bed16bf208
parent0e0d6c2b46837291273f2e1ef7be62a206a997ef (diff)
downloadbfs-2aceb02c680b689e7cecb07573347418f2dd03be.tar.xz
util: Preserve errno in pipe_cloexec()
-rw-r--r--util.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/util.c b/util.c
index aa6f401..aaddaa0 100644
--- a/util.c
+++ b/util.c
@@ -129,8 +129,10 @@ int pipe_cloexec(int pipefd[2]) {
}
if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) == -1 || fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) == -1) {
+ int error = errno;
close(pipefd[1]);
close(pipefd[0]);
+ errno = error;
return -1;
}