diff options
author | Paul Smith <psmith@gnu.org> | 2009-06-07 17:40:06 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2009-06-07 17:40:06 +0000 |
commit | 0b30c8d9cef18f55e2425e32ffc1552af650a1be (patch) | |
tree | 40d5d983e80d10d04bee39765bf904c7b83d0f53 /main.c | |
parent | 668af4698040c6524f93165300e0f9a84312ea66 (diff) | |
download | gunmake-0b30c8d9cef18f55e2425e32ffc1552af650a1be.tar.gz |
- Add a new test suite for LIBPATTERNS
- Fix Savannah bug #21198
- Fix Savannah bug #21823
- Fix Savannah bug #22010
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -44,14 +44,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */ # 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 @@ -220,6 +212,13 @@ int print_version_flag = 0; static struct stringlist *makefiles = 0; +/* Size of the stack when we started. */ + +#ifdef SET_STACK_SIZE +struct rlimit stack_limit; +#endif + + /* Number of job slots (commands that can be run at once). */ unsigned int job_slots = 1; @@ -928,11 +927,15 @@ main (int argc, char **argv, char **envp) struct rlimit rlim; /* Set the stack limit huge so that alloca does not fail. */ - if (getrlimit (RLIMIT_STACK, &rlim) == 0) + if (getrlimit (RLIMIT_STACK, &rlim) == 0 + && rlim.rlim_cur > 0 && rlim.rlim_cur < rlim.rlim_max) { + stack_limit = rlim; rlim.rlim_cur = rlim.rlim_max; setrlimit (RLIMIT_STACK, &rlim); } + else + stack_limit.rlim_cur = 0; } #endif |