summaryrefslogtreecommitdiff
path: root/src/pciaccess_private.h
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2012-02-27 11:19:50 -0500
committerAdam Jackson <ajax@redhat.com>2012-02-27 17:09:01 -0500
commitd2dc9f9daa45504f035b169aba94d0b154fd29f0 (patch)
tree28ccca7fd1ab27a208a9fbd73306c922d19dac86 /src/pciaccess_private.h
parentf550c1347d3518874fe1c1d417a57322ee6b52db (diff)
Use O_CLOEXEC for internal file descriptors
Well, almost all of them. zlib doesn't support "e" in the mode string in gzopen() though it will silently accept and ignore it, and Solaris appears not to support "e" in the mode string at all. Signed-off-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'src/pciaccess_private.h')
-rw-r--r--src/pciaccess_private.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pciaccess_private.h b/src/pciaccess_private.h
index 32f8a75..fea9c9f 100644
--- a/src/pciaccess_private.h
+++ b/src/pciaccess_private.h
@@ -37,6 +37,19 @@
# define _pci_hidden
#endif /* GNUC >= 4 */
+/*
+ * O_CLOEXEC fixes an fd leak case (see 'man 2 open' for details). I don't
+ * know of any OS we support where this isn't available in a sufficiently
+ * new version, so warn unconditionally.
+ */
+#include <sys/fcntl.h>
+
+#ifndef O_CLOEXEC
+#warning O_CLOEXEC not available, please upgrade.
+#define O_CLOEXEC 0
+#endif
+
+
struct pci_device_mapping;
int pci_fill_capabilities_generic( struct pci_device * dev );