summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2005-02-16 05:03:42 +0000
committerPaul Smith <psmith@gnu.org>2005-02-16 05:03:42 +0000
commite8ca9b8eb1caaa43703f6ce505af78c6e7b9e60b (patch)
tree06c563611aef3116a6f2de2844082f4609982039 /main.c
parentc90f47e8320b41e3a5bfeb654543d9474f763e5d (diff)
downloadgunmake-e8ca9b8eb1caaa43703f6ce505af78c6e7b9e60b.tar.gz
Add a patch from Paul Eggert that's been lying around in my directory for
a long time, disabling stack size limits where possible. Update version to beta2.
Diffstat (limited to 'main.c')
-rw-r--r--main.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/main.c b/main.c
index 726729b..33c15b4 100644
--- a/main.c
+++ b/main.c
@@ -46,6 +46,14 @@ MA 02111-1307, USA. */
# include <fcntl.h>
#endif
+#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
+# define SET_STACK_SIZE
+#endif
+
+#ifdef SET_STACK_SIZE
+# include <sys/resource.h>
+#endif
+
#ifdef _AMIGA
int __stack = 20000; /* Make sure we have 20K of stack space */
#endif
@@ -881,6 +889,20 @@ main (int argc, char **argv, char **envp)
no_default_sh_exe = 1;
#endif
+#ifdef SET_STACK_SIZE
+ /* Get rid of any avoidable limit on stack size. */
+ {
+ struct rlimit rlim;
+
+ /* Set the stack limit huge so that alloca does not fail. */
+ if (getrlimit (RLIMIT_STACK, &rlim) == 0)
+ {
+ rlim.rlim_cur = rlim.rlim_max;
+ setrlimit (RLIMIT_STACK, &rlim);
+ }
+ }
+#endif
+
/* Needed for OS/2 */
initialize_main(&argc, &argv);