summaryrefslogtreecommitdiff
path: root/src/xine-utils/xine_check.c
diff options
context:
space:
mode:
authorChris Rankin <rankincj@yahoo.com>2011-10-03 01:34:37 +0100
committerChris Rankin <rankincj@yahoo.com>2011-10-03 01:34:37 +0100
commit154d771692a1ca9b9af5eb0acc12885ca852307a (patch)
tree1ecf86dfa2c8c0397bc7b23a48886009ebecdb7e /src/xine-utils/xine_check.c
parentd7c4d2bd622b1405ff520006dbeaf739e9725a89 (diff)
downloadxine-lib-154d771692a1ca9b9af5eb0acc12885ca852307a.tar.gz
xine-lib-154d771692a1ca9b9af5eb0acc12885ca852307a.tar.bz2
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.
Diffstat (limited to 'src/xine-utils/xine_check.c')
-rw-r--r--src/xine-utils/xine_check.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/xine-utils/xine_check.c b/src/xine-utils/xine_check.c
index b0a252b6f..3c860493b 100644
--- a/src/xine-utils/xine_check.c
+++ b/src/xine-utils/xine_check.c
@@ -46,6 +46,10 @@
#include <xine/xineutils.h>
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0
+#endif
+
#if defined(__linux__)
#include <dlfcn.h>
@@ -168,7 +172,7 @@ static xine_health_check_t* _x_health_check_cdrom (xine_health_check_t* hc) {
return hc;
}
- if ( (fd = open(hc->cdrom_dev, O_RDWR)) < 0) {
+ if ( (fd = open(hc->cdrom_dev, O_RDWR | O_CLOEXEC)) < 0) {
switch (errno) {
case EACCES:
set_hc_result (hc, XINE_HEALTH_CHECK_FAIL, "FAILED - %s permissions are not sufficient\n.", hc->cdrom_dev);
@@ -204,7 +208,7 @@ static xine_health_check_t* _x_health_check_dvdrom(xine_health_check_t* hc) {
return hc;
}
- if ( (fd = open(hc->dvd_dev, O_RDWR)) < 0) {
+ if ( (fd = open(hc->dvd_dev, O_RDWR | O_CLOEXEC)) < 0) {
switch (errno) {
case EACCES:
set_hc_result (hc, XINE_HEALTH_CHECK_FAIL, "FAILED - %s permissions are not sufficient\n.", hc->dvd_dev);
@@ -247,7 +251,7 @@ static xine_health_check_t* _x_health_check_dma (xine_health_check_t* hc) {
return hc;
}
- fd = open (hc->dvd_dev, O_RDONLY | O_NONBLOCK);
+ fd = open (hc->dvd_dev, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
if (fd < 0) {
set_hc_result(hc, XINE_HEALTH_CHECK_FAIL, "FAILED - Could not open %s.\n", hc->dvd_dev);
return hc;