changeset 60 | 47c13ca8c4d0 |
parent 51 | a03372ef9714 |
child 77 | 49e0babccb23 |
--- a/set_limit.c +++ b/set_limit.c @@ -3,9 +3,11 @@ * Copyright (C) 2008 Markus Broeker */ -#include <sys/time.h> +#include <errno.h> #include <sys/resource.h> +#define MINIMUM (2*1024*1024) + int set_limit (int megs) { struct rlimit rlim; @@ -14,8 +16,10 @@ rlim.rlim_cur = megs; rlim.rlim_max = 1.25 * megs; - if (megs > (4 * 1024 * 1024)) + if (megs >= MINIMUM) return setrlimit (RLIMIT_AS, &rlim); + errno = ENOMEM; + return -1; }