diff --git a/builtin_ulimit.c b/builtin_ulimit.c index 49eda1a6b..40c089020 100644 --- a/builtin_ulimit.c +++ b/builtin_ulimit.c @@ -64,10 +64,12 @@ const static struct resource_t resource_arr[] = RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u' } , +#if HAVE_RLIMIT_AS { RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v' } , +#endif { 0, 0 } @@ -355,9 +357,11 @@ int builtin_ulimit( wchar_t ** argv ) what=RLIMIT_NPROC; break; +#if HAVE_RLIMIT_AS case L'v': what=RLIMIT_AS; break; +#endif case L'?': builtin_print_help( argv[0], sb_err ); diff --git a/config.h.in b/config.h.in index 0250a5229..ee6ab93cc 100644 --- a/config.h.in +++ b/config.h.in @@ -27,6 +27,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NCURSES_H +/* Define to 1 if HAVE_RLIMIT_AS is defined in . */ +#undef HAVE_RLIMIT_AS + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H @@ -39,6 +42,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_RESOURCE_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H diff --git a/configure.ac b/configure.ac index 0d6d05fba..23a3dc0a2 100644 --- a/configure.ac +++ b/configure.ac @@ -71,7 +71,19 @@ AC_CHECK_FILE([/usr/pkg/lib],[AC_SUBST(LIBDIR,[-L/usr/pkg/lib\ -R/usr/pkg/lib])] AC_CHECK_FILE([/usr/pkg/include],[AC_SUBST(INCLUDEDIR,[-I/usr/pkg/include])]) AC_CHECK_FUNCS( [wprintf futimes wcwidth wcswidth] ) -AC_CHECK_HEADERS([getopt.h termio.h]) +AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h]) + +# Check for RLIMIT_AS in sys/resource.h. +AC_MSG_CHECKING([for RLIMIT_AS in sys/resource.h]) +AC_TRY_COMPILE([#include ], +[int tmp; tmp=RLIMIT_AS;], have_rlimit_as=yes, have_rlimit_as=no) +if test "$have_rlimit_as" = yes; then + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_RLIMIT_AS], [1], + [Define to 1 if HAVE_RLIMIT_AS is defined in .]) +else + AC_MSG_RESULT(no) +fi AC_CHECK_LIB(socket, connect) AC_CHECK_LIB(rt, nanosleep) diff --git a/doc_src/ulimit.txt b/doc_src/ulimit.txt index 26897568a..ac21550c0 100644 --- a/doc_src/ulimit.txt +++ b/doc_src/ulimit.txt @@ -30,7 +30,7 @@ value. Other options are interpreted as follows: - -s or --stack-size The maximum stack size - -t or --cpu-time The maximum amount of cpu time in seconds - -u or --process-count The maximum number of processes available to a single user -- -v or --virtual-memory-size The maximum amount of virtual memory available to the shell +- -v or --virtual-memory-size The maximum amount of virtual memory available to the shell. If supported by OS. If limit is given, it is the new value of the specified resource. If no option is given, then -f is assumed. Values are in kilobytes, diff --git a/env_universal.c b/env_universal.c index 9e9d8839e..0a2aaadd5 100644 --- a/env_universal.c +++ b/env_universal.c @@ -1,3 +1,5 @@ +#include "config.h" + #include #include #include