From 154d771692a1ca9b9af5eb0acc12885ca852307a Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Mon, 3 Oct 2011 01:34:37 +0100 Subject: Mark simple file and socket descriptors as uninheritable. This patch creates two utility functions: int open_cloexec(pathname, flags) int create_cloexec(pathname, flags, mode) These return a file descriptor with the CLOEXEC flag set, to ensure that the descriptor is not inherited across a fork/exec operation. The sockets returned by: _x_io_tcp_connect_ipv4() _x_io_tcp_connect() now also have their CLOEXEC flag set. --- include/xine/xineutils.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/xine/xineutils.h') diff --git a/include/xine/xineutils.h b/include/xine/xineutils.h index 6c62bb84f..8b1860ea6 100644 --- a/include/xine/xineutils.h +++ b/include/xine/xineutils.h @@ -181,6 +181,18 @@ void xine_usec_sleep(unsigned usec) XINE_PROTECTED; */ char *xine_strcat_realloc (char **dest, char *append) XINE_PROTECTED; +/** + * opens a file, ensuring that the descriptor will be closed + * automatically after a fork/execute. + */ +int open_cloexec(const char *name, int flags) XINE_PROTECTED; + +/** + * creates a file, ensuring that the descriptor will be closed + * automatically after a fork/execute. + */ +int create_cloexec(const char *name, int flags, mode_t mode) XINE_PROTECTED; + /* * Color Conversion Utility Functions * The following data structures and functions facilitate the conversion -- cgit v1.2.3