From 2aceb02c680b689e7cecb07573347418f2dd03be Mon Sep 17 00:00:00 2001
From: Tavian Barnes <tavianator@tavianator.com>
Date: Tue, 24 Jul 2018 21:20:12 -0400
Subject: util: Preserve errno in pipe_cloexec()

---
 util.c | 2 ++
 1 file changed, 2 insertions(+)

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;
 	}
 
-- 
cgit v1.2.3