Here is the compile-tested patch for using O_CLOEXEC:
diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c
index 7f7b3ac..1cb86e6 100644
--- a/builds/unix/ftsystem.c
+++ b/builds/unix/ftsystem.c
@@ -238,7 +238,11 @@
return FT_THROW( Invalid_Stream_Handle );
/* open the file */
+#ifdef O_CLOEXEC
+ file = open( filepathname, O_RDONLY | O_CLOEXEC );
+#else
file = open( filepathname, O_RDONLY );
+#endif
if ( file < 0 )
{
FT_ERROR(( "FT_Stream_Open:" ));
@@ -251,6 +255,7 @@
/* since it avoids some (possible) access control */
/* issues and cleans up the kernel file table a bit. */
/* */
+#ifndef O_CLOEXEC
#ifdef F_SETFD
#ifdef FD_CLOEXEC
(void)fcntl( file, F_SETFD, FD_CLOEXEC );
@@ -258,6 +263,7 @@
(void)fcntl( file, F_SETFD, 1 );
#endif /* FD_CLOEXEC */
#endif /* F_SETFD */
+#endif /* !O_CLOEXEC */
if ( fstat( file, &stat_buf ) < 0 )
{
Let me know if I need to state anything about this being in the public domain, copyright assignment, etc...
-Kenny