aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorPaul Eggert2013-07-16 00:05:41 -0700
committerPaul Eggert2013-07-16 00:05:41 -0700
commitc7ddc792b747fdf4fde822df0cf9c7b712be4219 (patch)
treede532bf42e3675fa093996b13ddb490cb8ec2f6c /src/sysdep.c
parente6c005c5f8e39252fd11821b6452843bead2df6a (diff)
downloademacs-c7ddc792b747fdf4fde822df0cf9c7b712be4219.tar.gz
emacs-c7ddc792b747fdf4fde822df0cf9c7b712be4219.zip
Fix porting bug to older POSIXish platforms.
* sysdep.c (emacs_pipe): New function, that implements pipe2 (fd, O_CLOEXEC) even on hosts that lack O_CLOEXEC. This should port better to CentOS 5 and to Mac OS X 10.6. All calls to pipe2 changed. Fixes: debbugs:14862
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index f614d8bc557..82f490e9538 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -2201,6 +2201,20 @@ emacs_fopen (char const *file, char const *mode)
2201 return fd < 0 ? 0 : fdopen (fd, mode); 2201 return fd < 0 ? 0 : fdopen (fd, mode);
2202} 2202}
2203 2203
2204/* Create a pipe for Emacs use. */
2205
2206int
2207emacs_pipe (int fd[2])
2208{
2209 int result = pipe2 (fd, O_CLOEXEC);
2210 if (! O_CLOEXEC && result == 0)
2211 {
2212 fcntl (fd[0], F_SETFD, FD_CLOEXEC);
2213 fcntl (fd[1], F_SETFD, FD_CLOEXEC);
2214 }
2215 return result;
2216}
2217
2204/* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs. 2218/* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs.
2205 For the background behind this mess, please see Austin Group defect 529 2219 For the background behind this mess, please see Austin Group defect 529
2206 <http://austingroupbugs.net/view.php?id=529>. */ 2220 <http://austingroupbugs.net/view.php?id=529>. */