From 2139175bdcc8a78a606369b3bd72a320a1b6947a Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov@gmail.com>
Date: Mon, 2 Mar 2020 15:46:55 +0300
Subject: [PATCH] popen: close_inherited_fds - add support for macos/freebsd

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 src/lib/core/popen.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c
index 0e2d9dd009..ce7d7fff75 100644
--- a/src/lib/core/popen.c
+++ b/src/lib/core/popen.c
@@ -529,8 +529,11 @@ make_pipe(int pfd[2])
 static int
 close_inherited_fds(int *skip_fds, size_t nr_skip_fds)
 {
-#ifdef TARGET_OS_LINUX
+# if defined(TARGET_OS_LINUX)
 	static const char path[] = "/proc/self/fd";
+# else
+	static const char path[] = "/dev/fd";
+# endif
 	struct dirent *de;
 	int fd_no, fd_dir;
 	DIR *dir;
@@ -577,17 +580,6 @@ close_inherited_fds(int *skip_fds, size_t nr_skip_fds)
 		diag_set(SystemError, "fdin: Can't close %s", path);
 		return -1;
 	}
-#else
-	/* FIXME: What about FreeBSD/MachO? */
-	(void)skip_fds;
-	(void)nr_skip_fds;
-
-	static bool said = false;
-	if (!said) {
-		say_warn("popen: fdin: Skip closing inherited");
-		said = true;
-	}
-#endif
 	return 0;
 }
 
-- 
GitLab