components/python/python26/patches/Python26-19-ext-stdio.patch
author Norm Jacobs <Norm.Jacobs@Oracle.COM>
Tue, 01 Mar 2011 14:19:15 -0800
changeset 115 c360825c3a3f
parent 99 components/python/python26/Python26-19-ext-stdio.patch@c15c9099bb44
child 276 18dcd0ca5b0c
permissions -rw-r--r--
7022166 userland patches should move to subdirs

diff --git Python-2.6.4/Modules/python.c Python-2.6.4/Modules/python.c
--- Python-2.6.4/Modules/python.c
+++ Python-2.6.4/Modules/python.c
@@ -6,6 +6,13 @@
 #include <floatingpoint.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)
 {
@@ -20,5 +27,16 @@
 	m = fpgetmask();
 	fpsetmask(m & ~FP_X_OFL);
 #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, SIGABRT);
+	}
+#endif
+
 	return Py_Main(argc, argv);
 }