diff options
| author | Chris Rankin <rankincj@yahoo.com> | 2011-10-03 21:27:57 +0100 |
|---|---|---|
| committer | Chris Rankin <rankincj@yahoo.com> | 2011-10-03 21:27:57 +0100 |
| commit | 7a585790118e837ec788ac9b3e4cf6a381c61234 (patch) | |
| tree | 9d60c2cce1518d75c9b0bd1bc31e278e74cc7f3f /src/xine-utils | |
| parent | a39a950269d165f18448cc7d6da691bf14b9e03b (diff) | |
| download | xine-lib-7a585790118e837ec788ac9b3e4cf6a381c61234.tar.gz xine-lib-7a585790118e837ec788ac9b3e4cf6a381c61234.tar.bz2 | |
Set CLOEXEC flag on three more sockets.
There are two functions that actually set this flag:
int _x_set_file_close_on_exec()
int _x_set_socket_close_on_exec()
(We need two functions because file descriptors and sockets
are not the same under WIN32 - of course).
These function belong to libxine's internal API, i.e. they are
not available for use by plugins.
Diffstat (limited to 'src/xine-utils')
| -rw-r--r-- | src/xine-utils/utils.c | 22 |
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; |
