Do not use RLIMIT_AS on systems that don't have it, like NetBSD

darcs-hash:20051017133657-ac50b-b27739229dfa6b3f08c2e9e7f4577cdceaf09beb.gz
This commit is contained in:
axel 2005-10-17 23:36:57 +10:00
parent d17f6b7ce4
commit f87178420a
5 changed files with 26 additions and 2 deletions

View file

@ -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 );

View file

@ -27,6 +27,9 @@
/* Define to 1 if you have the <ncurses.h> header file. */
#undef HAVE_NCURSES_H
/* Define to 1 if HAVE_RLIMIT_AS is defined in <sys/resource.h>. */
#undef HAVE_RLIMIT_AS
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@ -39,6 +42,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H

View file

@ -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 <sys/resource.h>],
[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 <sys/resource.h>.])
else
AC_MSG_RESULT(no)
fi
AC_CHECK_LIB(socket, connect)
AC_CHECK_LIB(rt, nanosleep)

View file

@ -30,7 +30,7 @@ value. Other options are interpreted as follows:
- <code>-s</code> or <code>--stack-size</code> The maximum stack size
- <code>-t</code> or <code>--cpu-time</code> The maximum amount of cpu time in seconds
- <code>-u</code> or <code>--process-count</code> The maximum number of processes available to a single user
- <code>-v</code> or <code>--virtual-memory-size</code> The maximum amount of virtual memory available to the shell
- <code>-v</code> or <code>--virtual-memory-size</code> 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,

View file

@ -1,3 +1,5 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>