summaryrefslogtreecommitdiff
path: root/src/xine-utils/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-utils/utils.c')
-rw-r--r--src/xine-utils/utils.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c
index 61f2d71c5..bc5f1a228 100644
--- a/src/xine-utils/utils.c
+++ b/src/xine-utils/utils.c
@@ -32,6 +32,7 @@
#ifdef _MSC_VER
#include <xine/xine_internal.h>
#endif
+#include "xine_private.h"
#include <errno.h>
#include <pwd.h>
@@ -726,7 +727,7 @@ char *xine_strcat_realloc (char **dest, char *append)
}
-static int set_close_on_execute(int fd)
+int _x_set_file_close_on_exec(int fd)
{
#ifndef WIN32
return fcntl(fd, F_SETFD, FD_CLOEXEC);
@@ -735,13 +736,22 @@ static int set_close_on_execute(int fd)
#endif
}
+int _x_set_socket_close_on_exec(int s)
+{
+#ifndef WIN32
+ return fcntl(s, F_SETFD, FD_CLOEXEC);
+#else
+ return SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0);
+#endif
+}
+
int xine_open_cloexec(const char *name, int flags)
{
int fd = open(name, (flags | O_CLOEXEC));
if (fd >= 0) {
- set_close_on_execute(fd);
+ _x_set_file_close_on_exec(fd);
}
return fd;
@@ -752,7 +762,7 @@ int xine_create_cloexec(const char *name, int flags, mode_t mode)
int fd = open(name, (flags | O_CREAT | O_CLOEXEC), mode);
if (fd >= 0) {
- set_close_on_execute(fd);
+ _x_set_file_close_on_exec(fd);
}
return fd;
@@ -763,11 +773,7 @@ int xine_socket_cloexec(int domain, int type, int protocol)
int s = socket(domain, type, protocol);
if (s >= 0) {
-#ifndef WIN32
- fcntl(s, F_SETFD, FD_CLOEXEC);
-#else
- SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0);
-#endif
+ _x_set_socket_close_on_exec(s);
}
return s;