mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
builtin ulimit checks
Adds checks for RLIMIT_NPROC, RLIMIT_RSS and RLIMIT_MEMLOCK not available on all platforms. darcs-hash:20051124111321-cac88-606a61ca0f3baa69115be658a056f42a5a9318ad.gz
This commit is contained in:
parent
7d334914f7
commit
82cb97d3e3
2 changed files with 56 additions and 5 deletions
|
@ -55,14 +55,18 @@ const static struct resource_t resource_arr[] =
|
|||
RLIMIT_FSIZE, L"Maximum size of files created by the shell", L'f'
|
||||
}
|
||||
,
|
||||
#if HAVE_RLIMIT_MEMLOCK
|
||||
{
|
||||
RLIMIT_MEMLOCK, L"Maximum size that may be locked into memory", L'l'
|
||||
}
|
||||
,
|
||||
#endif
|
||||
#if HAVE_RLIMIT_RSS
|
||||
{
|
||||
RLIMIT_RSS, L"Maximum resident set size", L'm'
|
||||
}
|
||||
,
|
||||
#endif
|
||||
{
|
||||
RLIMIT_NOFILE, L"Maximum number of open file descriptors", L'n'
|
||||
}
|
||||
|
@ -75,10 +79,12 @@ const static struct resource_t resource_arr[] =
|
|||
RLIMIT_CPU, L"Maximum amount of cpu time in seconds", L't'
|
||||
}
|
||||
,
|
||||
#if HAVE_RLIMIT_NPROC
|
||||
{
|
||||
RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u'
|
||||
}
|
||||
,
|
||||
#endif
|
||||
#if HAVE_RLIMIT_AS
|
||||
{
|
||||
RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v'
|
||||
|
@ -96,8 +102,11 @@ const static struct resource_t resource_arr[] =
|
|||
*/
|
||||
static int get_multiplier( int what )
|
||||
{
|
||||
if( ( what == RLIMIT_NPROC ) ||
|
||||
( what == RLIMIT_NOFILE ) ||
|
||||
|
||||
if( ( what == RLIMIT_NOFILE ) ||
|
||||
#if HAVE_RLIMIT_NPROC
|
||||
( what == RLIMIT_NPROC ) ||
|
||||
#endif
|
||||
( what == RLIMIT_CPU ) )
|
||||
{
|
||||
return 1;
|
||||
|
@ -365,14 +374,17 @@ int builtin_ulimit( wchar_t ** argv )
|
|||
case L'f':
|
||||
what=RLIMIT_FSIZE;
|
||||
break;
|
||||
|
||||
#if HAVE_RLIMIT_MEMLOCK
|
||||
case L'l':
|
||||
what=RLIMIT_MEMLOCK;
|
||||
break;
|
||||
|
||||
#endif
|
||||
|
||||
#if HAVE_RLIMIT_RSS
|
||||
case L'm':
|
||||
what=RLIMIT_RSS;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case L'n':
|
||||
what=RLIMIT_NOFILE;
|
||||
|
@ -385,10 +397,12 @@ int builtin_ulimit( wchar_t ** argv )
|
|||
case L't':
|
||||
what=RLIMIT_CPU;
|
||||
break;
|
||||
|
||||
|
||||
#if HAVE_RLIMIT_NPROC
|
||||
case L'u':
|
||||
what=RLIMIT_NPROC;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if HAVE_RLIMIT_AS
|
||||
case L'v':
|
||||
|
|
37
configure.ac
37
configure.ac
|
@ -79,6 +79,43 @@ else
|
|||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for RLIMIT_MEMLOCK in sys/resource.h.
|
||||
AC_MSG_CHECKING([for RLIMIT_MEMLOCK in sys/resource.h])
|
||||
AC_TRY_COMPILE([#include <sys/resource.h>],
|
||||
[int tmp; tmp=RLIMIT_MEMLOCK;], have_rlimit_as=yes, have_rlimit_as=no)
|
||||
if test "$have_rlimit_as" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_RLIMIT_MEMLOCK], [1],
|
||||
[Define to 1 if HAVE_RLIMIT_MEMLOCK is defined in <sys/resource.h>.])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for RLIMIT_RSS in sys/resource.h.
|
||||
AC_MSG_CHECKING([for RLIMIT_RSS in sys/resource.h])
|
||||
AC_TRY_COMPILE([#include <sys/resource.h>],
|
||||
[int tmp; tmp=RLIMIT_RSS;], have_rlimit_as=yes, have_rlimit_as=no)
|
||||
if test "$have_rlimit_as" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_RLIMIT_RSS], [1],
|
||||
[Define to 1 if HAVE_RLIMIT_RSS is defined in <sys/resource.h>.])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for RLIMIT_NPROC in sys/resource.h.
|
||||
AC_MSG_CHECKING([for RLIMIT_NPROC in sys/resource.h])
|
||||
AC_TRY_COMPILE([#include <sys/resource.h>],
|
||||
[int tmp; tmp=RLIMIT_NPROC;], have_rlimit_as=yes, have_rlimit_as=no)
|
||||
if test "$have_rlimit_as" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_RLIMIT_NPROC], [1],
|
||||
[Define to 1 if HAVE_RLIMIT_NPROC is defined in <sys/resource.h>.])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
AC_CHECK_LIB(socket, connect)
|
||||
AC_CHECK_LIB(rt, nanosleep)
|
||||
|
||||
|
|
Loading…
Reference in a new issue