summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/core-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-10-30 04:16:59 +0100
committerLennart Poettering <lennart@poettering.net>2009-10-30 04:16:59 +0100
commita698ee3f52e9d61b378cb0dad2cfb1bcc31c708a (patch)
tree768765abd81279e6fcc363ec3540e036d7c08125 /src/pulsecore/core-util.c
parent65e7bc18a9a7b89e55b87a74ae47d45269b51847 (diff)
core-util: make sure to enable FD_CLOEXEC unconditionally to cope with kernels that silently accept but ignore O_CLOEXEC
Diffstat (limited to 'src/pulsecore/core-util.c')
-rw-r--r--src/pulsecore/core-util.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 19e12963..a199daa3 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2896,7 +2896,7 @@ int pa_open_cloexec(const char *fn, int flags, mode_t mode) {
#ifdef O_CLOEXEC
if ((fd = open(fn, flags|O_CLOEXEC, mode)) >= 0)
- return fd;
+ goto finish;
if (errno != EINVAL)
return fd;
@@ -2905,6 +2905,10 @@ int pa_open_cloexec(const char *fn, int flags, mode_t mode) {
if ((fd = open(fn, flags, mode)) < 0)
return fd;
+finish:
+ /* Some implementations might simply ignore O_CLOEXEC if it is not
+ * understood, make sure FD_CLOEXEC is enabled anyway */
+
pa_make_fd_cloexec(fd);
return fd;
}
@@ -2914,7 +2918,7 @@ int pa_socket_cloexec(int domain, int type, int protocol) {
#ifdef SOCK_CLOEXEC
if ((fd = socket(domain, type | SOCK_CLOEXEC, protocol)) >= 0)
- return fd;
+ goto finish;
if (errno != EINVAL)
return fd;
@@ -2923,6 +2927,10 @@ int pa_socket_cloexec(int domain, int type, int protocol) {
if ((fd = socket(domain, type, protocol)) < 0)
return fd;
+finish:
+ /* Some implementations might simply ignore SOCK_CLOEXEC if it is
+ * not understood, make sure FD_CLOEXEC is enabled anyway */
+
pa_make_fd_cloexec(fd);
return fd;
}
@@ -2932,7 +2940,7 @@ int pa_pipe_cloexec(int pipefd[2]) {
#ifdef HAVE_PIPE2
if ((r = pipe2(pipefd, O_CLOEXEC)) >= 0)
- return r;
+ goto finish;
if (errno != EINVAL && errno != ENOSYS)
return r;
@@ -2941,6 +2949,7 @@ int pa_pipe_cloexec(int pipefd[2]) {
if ((r = pipe(pipefd)) < 0)
return r;
+finish:
pa_make_fd_cloexec(pipefd[0]);
pa_make_fd_cloexec(pipefd[1]);