components/python/python27/patches/01-ext-stdio.patch
author John Beck <John.Beck@Oracle.COM>
Thu, 21 Jul 2016 12:51:35 -0700
changeset 6445 0edecb568b2e
parent 1954 32663e59626d
permissions -rw-r--r--
23858073 Upgrade Python 2.7 line to 2.7.12

This patch provides extended file stdio support.
As it is Solaris-specific, it is not suitable for upstream.

--- Python-2.7.12/Modules/python.c.~1~	2016-06-25 14:49:31.000000000 -0700
+++ Python-2.7.12/Modules/python.c	2016-07-07 13:39:38.170867069 -0700
@@ -6,6 +6,13 @@
 #include <fenv.h>
 #endif
 
+#if defined(sun) && defined(__SVR4) && !defined(_LP64)
+#define USE_EXTENDED_FILE_STDIO 1
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <signal.h>
+#endif
+
 int
 main(int argc, char **argv)
 {
@@ -17,5 +24,18 @@
 #ifdef __FreeBSD__
 	fedisableexcept(FE_OVERFLOW);
 #endif
+#ifdef USE_EXTENDED_FILE_STDIO
+	/*
+	 * enable extended FILE facility on Solaris so that Python
+	 * apps can keep more than 256 file descriptors open
+	 */
+	struct rlimit rlp;
+	(void) getrlimit(RLIMIT_NOFILE, &rlp);
+	rlp.rlim_cur = rlp.rlim_max;
+	if (setrlimit(RLIMIT_NOFILE, &rlp) != -1) {
+		enable_extended_FILE_stdio(-1, 0);
+	}
+#endif
+
 	return Py_Main(argc, argv);
 }