[Gridflow-cvs] [svn] commit: r4216 - /trunk/gridflow.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Oct 16 08:56:39 EDT 2009


Author: matju
Date: Fri Oct 16 08:56:38 2009
New Revision: 4216

Log:
automatic ulimit -Ss $(ulimit -Hs)

Modified:
    trunk/gridflow.c

Modified: trunk/gridflow.c
==============================================================================
--- trunk/gridflow.c (original)
+++ trunk/gridflow.c Fri Oct 16 08:56:38 2009
@@ -26,6 +26,8 @@
 #include <stdarg.h>
 #include <unistd.h>
 #include <sys/time.h>
+#include <sys/resource.h>
+#include <errno.h>
 #include <signal.h>
 #include <setjmp.h>
 #include <stdlib.h>
@@ -886,6 +888,17 @@
 */
 }
 
+void allow_big_stack () {
+  struct rlimit happy;
+  if (0>getrlimit(RLIMIT_STACK,&happy))
+    error("GF: getrlimit: %s",strerror(errno));
+  happy.rlim_cur = happy.rlim_max;
+  if (0>setrlimit(RLIMIT_STACK,&happy))
+    error("GF: setting stack size to %ld: %s",happy.rlim_cur,strerror(errno));
+  else
+    post( "GF: setting stack size to %ld",happy.rlim_cur);
+}
+
 // note: contrary to what m_pd.h says, pd_getfilename() and pd_getdirname()
 // don't exist; also, canvas_getcurrentdir() isn't available during setup
 // (segfaults), in addition to libraries not being canvases ;-)
@@ -895,6 +908,7 @@
     post("GridFlow was compiled on "__DATE__", "__TIME__);
     //std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
     std::set_terminate(blargh);
+    allow_big_stack();
     try {
 	char *dirname   = new char[MAXPDSTRING];
 	char *dirresult = new char[MAXPDSTRING];



More information about the Gridflow-cvs mailing list