annotate lib/pipe2.c @ 40231:9b3c79fdfe0b

strtod: fix clash with strtold Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817). * lib/strtod.c (compute_minus_zero, minus_zero): Simplify by remving the macro / external variable, and having just a function. User changed. This avoids the need for an external variable that might clash.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 11 Mar 2019 16:40:29 -0700
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Create a pipe, with specific opening flags.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19595
diff changeset
2 Copyright (C) 2009-2019 Free Software Foundation, Inc.
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 any later version.
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License along
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
15 with this program; if not, see <https://www.gnu.org/licenses/>. */
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 /* Specification. */
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #include <unistd.h>
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <errno.h>
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <fcntl.h>
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
17436
d8be19310ad9 accept4, dup3, pipe2: port to Cygwin
Paul Eggert <eggert@cs.ucla.edu>
parents: 17432
diff changeset
25 #include "binary-io.h"
14856
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
26 #include "verify.h"
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
27
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
28 #if GNULIB_defined_O_NONBLOCK
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
29 # include "nonblocking.h"
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
30 #endif
11900
ec8584c5c427 dup2, pipe2: fix some recent test failures on cygwin 1.5.x
Eric Blake <ebb9@byu.net>
parents: 11895
diff changeset
31
19595
beb2ad957aca Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
32 #if defined _WIN32 && ! defined __CYGWIN__
16242
59c686e5b2df Talk about "native Windows API", not "Woe32".
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
33 /* Native Windows API. */
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 # include <io.h>
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36
11892
26347f7d2cac Move #ifs inside function.
Bruno Haible <bruno@clisp.org>
parents: 11881
diff changeset
37 #endif
26347f7d2cac Move #ifs inside function.
Bruno Haible <bruno@clisp.org>
parents: 11881
diff changeset
38
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 int
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 pipe2 (int fd[2], int flags)
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 {
15326
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
42 /* Mingw _pipe() corrupts fd on failure; also, if we succeed at
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
43 creating the pipe but later fail at changing fcntl, we want
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
44 to leave fd unchanged: http://austingroupbugs.net/view.php?id=467 */
15327
5e07722935cf pipe2: fix C89 compile problem
Eric Blake <eblake@redhat.com>
parents: 15326
diff changeset
45 int tmp[2];
5e07722935cf pipe2: fix C89 compile problem
Eric Blake <eblake@redhat.com>
parents: 15326
diff changeset
46 tmp[0] = fd[0];
5e07722935cf pipe2: fix C89 compile problem
Eric Blake <eblake@redhat.com>
parents: 15326
diff changeset
47 tmp[1] = fd[1];
15326
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
48
11893
476cefda5290 Tolerate declared but missing pipe2 syscall.
Bruno Haible <bruno@clisp.org>
parents: 11892
diff changeset
49 #if HAVE_PIPE2
476cefda5290 Tolerate declared but missing pipe2 syscall.
Bruno Haible <bruno@clisp.org>
parents: 11892
diff changeset
50 # undef pipe2
476cefda5290 Tolerate declared but missing pipe2 syscall.
Bruno Haible <bruno@clisp.org>
parents: 11892
diff changeset
51 /* Try the system call first, if it exists. (We may be running with a glibc
476cefda5290 Tolerate declared but missing pipe2 syscall.
Bruno Haible <bruno@clisp.org>
parents: 11892
diff changeset
52 that has the function but with an older kernel that lacks it.) */
476cefda5290 Tolerate declared but missing pipe2 syscall.
Bruno Haible <bruno@clisp.org>
parents: 11892
diff changeset
53 {
11895
3ef16b8c79cd Avoid running into nonexistent system calls repeatedly.
Bruno Haible <bruno@clisp.org>
parents: 11893
diff changeset
54 /* Cache the information whether the system call really exists. */
3ef16b8c79cd Avoid running into nonexistent system calls repeatedly.
Bruno Haible <bruno@clisp.org>
parents: 11893
diff changeset
55 static int have_pipe2_really; /* 0 = unknown, 1 = yes, -1 = no */
3ef16b8c79cd Avoid running into nonexistent system calls repeatedly.
Bruno Haible <bruno@clisp.org>
parents: 11893
diff changeset
56 if (have_pipe2_really >= 0)
3ef16b8c79cd Avoid running into nonexistent system calls repeatedly.
Bruno Haible <bruno@clisp.org>
parents: 11893
diff changeset
57 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
58 int result = pipe2 (fd, flags);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
59 if (!(result < 0 && errno == ENOSYS))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
60 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
61 have_pipe2_really = 1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
62 return result;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
63 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
64 have_pipe2_really = -1;
11895
3ef16b8c79cd Avoid running into nonexistent system calls repeatedly.
Bruno Haible <bruno@clisp.org>
parents: 11893
diff changeset
65 }
11893
476cefda5290 Tolerate declared but missing pipe2 syscall.
Bruno Haible <bruno@clisp.org>
parents: 11892
diff changeset
66 }
476cefda5290 Tolerate declared but missing pipe2 syscall.
Bruno Haible <bruno@clisp.org>
parents: 11892
diff changeset
67 #endif
476cefda5290 Tolerate declared but missing pipe2 syscall.
Bruno Haible <bruno@clisp.org>
parents: 11892
diff changeset
68
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 /* Check the supported flags. */
14535
7ba508565384 pipe2: fix O_NONBLOCK support on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
70 if ((flags & ~(O_CLOEXEC | O_NONBLOCK | O_BINARY | O_TEXT)) != 0)
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 {
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 errno = EINVAL;
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 return -1;
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 }
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75
19595
beb2ad957aca Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
76 #if defined _WIN32 && ! defined __CYGWIN__
16242
59c686e5b2df Talk about "native Windows API", not "Woe32".
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
77 /* Native Windows API. */
14535
7ba508565384 pipe2: fix O_NONBLOCK support on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
78
14592
cc17a319ded6 pipe2: Simplify code.
Bruno Haible <bruno@clisp.org>
parents: 14535
diff changeset
79 if (_pipe (fd, 4096, flags & ~O_NONBLOCK) < 0)
15326
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
80 {
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
81 fd[0] = tmp[0];
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
82 fd[1] = tmp[1];
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
83 return -1;
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
84 }
14592
cc17a319ded6 pipe2: Simplify code.
Bruno Haible <bruno@clisp.org>
parents: 14535
diff changeset
85
14856
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
86 /* O_NONBLOCK handling.
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
87 On native Windows platforms, O_NONBLOCK is defined by gnulib. Use the
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
88 functions defined by the gnulib module 'nonblocking'. */
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
89 # if GNULIB_defined_O_NONBLOCK
14535
7ba508565384 pipe2: fix O_NONBLOCK support on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
90 if (flags & O_NONBLOCK)
7ba508565384 pipe2: fix O_NONBLOCK support on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
91 {
7ba508565384 pipe2: fix O_NONBLOCK support on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
92 if (set_nonblocking_flag (fd[0], true) != 0
7ba508565384 pipe2: fix O_NONBLOCK support on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
93 || set_nonblocking_flag (fd[1], true) != 0)
14592
cc17a319ded6 pipe2: Simplify code.
Bruno Haible <bruno@clisp.org>
parents: 14535
diff changeset
94 goto fail;
14535
7ba508565384 pipe2: fix O_NONBLOCK support on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
95 }
14856
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
96 # else
15754
05bdc6eefa07 pipe2: Fix compilation on pre-C99 compilers.
Bruno Haible <bruno@clisp.org>
parents: 15519
diff changeset
97 {
05bdc6eefa07 pipe2: Fix compilation on pre-C99 compilers.
Bruno Haible <bruno@clisp.org>
parents: 15519
diff changeset
98 verify (O_NONBLOCK == 0);
05bdc6eefa07 pipe2: Fix compilation on pre-C99 compilers.
Bruno Haible <bruno@clisp.org>
parents: 15519
diff changeset
99 }
14856
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
100 # endif
14592
cc17a319ded6 pipe2: Simplify code.
Bruno Haible <bruno@clisp.org>
parents: 14535
diff changeset
101
cc17a319ded6 pipe2: Simplify code.
Bruno Haible <bruno@clisp.org>
parents: 14535
diff changeset
102 return 0;
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 #else
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 /* Unix API. */
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 if (pipe (fd) < 0)
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 return -1;
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 /* POSIX <http://www.opengroup.org/onlinepubs/9699919799/functions/pipe.html>
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 says that initially, the O_NONBLOCK and FD_CLOEXEC flags are cleared on
14535
7ba508565384 pipe2: fix O_NONBLOCK support on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
112 both fd[0] and fd[1]. */
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113
14856
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
114 /* O_NONBLOCK handling.
c593fd7d2ab9 pipe2: Remove dependency on 'nonblocking' module.
Bruno Haible <bruno@clisp.org>
parents: 14592
diff changeset
115 On Unix platforms, O_NONBLOCK is defined by the system. Use fcntl(). */
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 if (flags & O_NONBLOCK)
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 {
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 int fcntl_flags;
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 if ((fcntl_flags = fcntl (fd[1], F_GETFL, 0)) < 0
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
121 || fcntl (fd[1], F_SETFL, fcntl_flags | O_NONBLOCK) == -1
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
122 || (fcntl_flags = fcntl (fd[0], F_GETFL, 0)) < 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
123 || fcntl (fd[0], F_SETFL, fcntl_flags | O_NONBLOCK) == -1)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
124 goto fail;
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 }
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 if (flags & O_CLOEXEC)
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 {
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 int fcntl_flags;
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 if ((fcntl_flags = fcntl (fd[1], F_GETFD, 0)) < 0
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
132 || fcntl (fd[1], F_SETFD, fcntl_flags | FD_CLOEXEC) == -1
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
133 || (fcntl_flags = fcntl (fd[0], F_GETFD, 0)) < 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
134 || fcntl (fd[0], F_SETFD, fcntl_flags | FD_CLOEXEC) == -1)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11900
diff changeset
135 goto fail;
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 }
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137
11892
26347f7d2cac Move #ifs inside function.
Bruno Haible <bruno@clisp.org>
parents: 11881
diff changeset
138 # if O_BINARY
11880
d5e0338c205a Support O_TEXT, O_BINARY on all platforms.
Bruno Haible <bruno@clisp.org>
parents: 11879
diff changeset
139 if (flags & O_BINARY)
11881
9e30ae0c65a0 Oops, fix last commit.
Bruno Haible <bruno@clisp.org>
parents: 11880
diff changeset
140 {
17436
d8be19310ad9 accept4, dup3, pipe2: port to Cygwin
Paul Eggert <eggert@cs.ucla.edu>
parents: 17432
diff changeset
141 set_binary_mode (fd[1], O_BINARY);
d8be19310ad9 accept4, dup3, pipe2: port to Cygwin
Paul Eggert <eggert@cs.ucla.edu>
parents: 17432
diff changeset
142 set_binary_mode (fd[0], O_BINARY);
11881
9e30ae0c65a0 Oops, fix last commit.
Bruno Haible <bruno@clisp.org>
parents: 11880
diff changeset
143 }
11880
d5e0338c205a Support O_TEXT, O_BINARY on all platforms.
Bruno Haible <bruno@clisp.org>
parents: 11879
diff changeset
144 else if (flags & O_TEXT)
11881
9e30ae0c65a0 Oops, fix last commit.
Bruno Haible <bruno@clisp.org>
parents: 11880
diff changeset
145 {
17436
d8be19310ad9 accept4, dup3, pipe2: port to Cygwin
Paul Eggert <eggert@cs.ucla.edu>
parents: 17432
diff changeset
146 set_binary_mode (fd[1], O_TEXT);
d8be19310ad9 accept4, dup3, pipe2: port to Cygwin
Paul Eggert <eggert@cs.ucla.edu>
parents: 17432
diff changeset
147 set_binary_mode (fd[0], O_TEXT);
11881
9e30ae0c65a0 Oops, fix last commit.
Bruno Haible <bruno@clisp.org>
parents: 11880
diff changeset
148 }
11892
26347f7d2cac Move #ifs inside function.
Bruno Haible <bruno@clisp.org>
parents: 11881
diff changeset
149 # endif
11880
d5e0338c205a Support O_TEXT, O_BINARY on all platforms.
Bruno Haible <bruno@clisp.org>
parents: 11879
diff changeset
150
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 return 0;
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152
14592
cc17a319ded6 pipe2: Simplify code.
Bruno Haible <bruno@clisp.org>
parents: 14535
diff changeset
153 #endif
cc17a319ded6 pipe2: Simplify code.
Bruno Haible <bruno@clisp.org>
parents: 14535
diff changeset
154
19595
beb2ad957aca Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
155 #if GNULIB_defined_O_NONBLOCK || !(defined _WIN32 && ! defined __CYGWIN__)
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156 fail:
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 {
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 int saved_errno = errno;
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 close (fd[0]);
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 close (fd[1]);
15326
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
161 fd[0] = tmp[0];
52719068f9c2 pipe, pipe2: don't corrupt fd on error
Eric Blake <eblake@redhat.com>
parents: 14856
diff changeset
162 fd[1] = tmp[1];
11870
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 errno = saved_errno;
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 return -1;
ddd29d8cdded New module 'pipe2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 }
15519
5b310380e54f pipe2: silence compiler warning
Eric Blake <eblake@redhat.com>
parents: 15327
diff changeset
166 #endif
11892
26347f7d2cac Move #ifs inside function.
Bruno Haible <bruno@clisp.org>
parents: 11881
diff changeset
167 }