aboutsummaryrefslogtreecommitdiffstats
path: root/src/fd_util.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-10 16:53:20 +0100
committerMax Kellermann <max@duempel.org>2009-11-10 16:53:20 +0100
commit3d2a9d35450876fe28708340e2b4ed3831d9d9af (patch)
treef9bc3f6dc823853a025f8f151658797e2cee2978 /src/fd_util.c
parent6975c087e069bd19cf4838836c1ef350480bb8dd (diff)
downloadmpd-3d2a9d35450876fe28708340e2b4ed3831d9d9af.tar.gz
mpd-3d2a9d35450876fe28708340e2b4ed3831d9d9af.tar.xz
mpd-3d2a9d35450876fe28708340e2b4ed3831d9d9af.zip
fd_util: added function pipe_cloexec()
Same as pipe_cloexec_nonblock(), but doesn't set non-blocking mode.
Diffstat (limited to '')
-rw-r--r--src/fd_util.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/fd_util.c b/src/fd_util.c
index 8f142e34a..f296aab97 100644
--- a/src/fd_util.c
+++ b/src/fd_util.c
@@ -140,6 +140,30 @@ creat_cloexec(const char *path_fs, int mode)
}
int
+pipe_cloexec(int fd[2])
+{
+#ifdef WIN32
+ return _pipe(event_pipe, 512, _O_BINARY);
+#else
+ int ret;
+
+#ifdef HAVE_PIPE2
+ ret = pipe2(fd, O_CLOEXEC);
+ if (ret >= 0 || errno != ENOSYS)
+ return ret;
+#endif
+
+ ret = pipe(fd);
+ if (ret >= 0) {
+ fd_set_cloexec(fd[0], true);
+ fd_set_cloexec(fd[1], true);
+ }
+
+ return ret;
+#endif
+}
+
+int
pipe_cloexec_nonblock(int fd[2])
{
#ifdef WIN32
@@ -158,10 +182,8 @@ pipe_cloexec_nonblock(int fd[2])
fd_set_cloexec(fd[0], true);
fd_set_cloexec(fd[1], true);
-#ifndef WIN32
fd_set_nonblock(fd[0]);
fd_set_nonblock(fd[1]);
-#endif
}
return ret;