From: Bruno Haible <bruno@clisp.org>
Date: Fri, 25 Dec 2020 01:16:18 +0000 (+0100)
Subject: unistd-safer: Implement pipe_safer on native Windows.
X-Git-Tag: v1.0~3307
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=8fede4db2de4fd41ddf7e57b2d2c0e23f5deef67;p=gnulib.git

unistd-safer: Implement pipe_safer on native Windows.

* lib/pipe-safer.c (pipe_safer): Don't test HAVE_PIPE.
* modules/unistd-safer (Depends-on): Add pipe-posix.
---

diff --git a/ChangeLog b/ChangeLog
index afc5829ebb..3d8478aebd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-24  Bruno Haible  <bruno@clisp.org>
+
+	unistd-safer: Implement pipe_safer on native Windows.
+	* lib/pipe-safer.c (pipe_safer): Don't test HAVE_PIPE.
+	* modules/unistd-safer (Depends-on): Add pipe-posix.
+
 2020-12-24  Bruno Haible  <bruno@clisp.org>
 
 	execute: Use posix_spawn by default on native Windows.
diff --git a/lib/pipe-safer.c b/lib/pipe-safer.c
index 5a597c5270..a90ed81b26 100644
--- a/lib/pipe-safer.c
+++ b/lib/pipe-safer.c
@@ -30,7 +30,6 @@
 int
 pipe_safer (int fd[2])
 {
-#if HAVE_PIPE
   if (pipe (fd) == 0)
     {
       int i;
@@ -39,18 +38,15 @@ pipe_safer (int fd[2])
           fd[i] = fd_safer (fd[i]);
           if (fd[i] < 0)
             {
-              int e = errno;
+              int saved_errno = errno;
               close (fd[1 - i]);
-              errno = e;
+              errno = saved_errno;
               return -1;
             }
         }
 
       return 0;
     }
-#else
-  errno = ENOSYS;
-#endif
 
   return -1;
 }
diff --git a/modules/unistd-safer b/modules/unistd-safer
index 2d195ecd12..d131b9c7a8 100644
--- a/modules/unistd-safer
+++ b/modules/unistd-safer
@@ -12,6 +12,7 @@ m4/unistd-safer.m4
 Depends-on:
 fcntl
 unistd
+pipe-posix
 
 configure.ac:
 gl_UNISTD_SAFER