1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-10 09:36:16 +02:00

18431: Another attempt to fix the problems with RLIMIT definitions

This commit is contained in:
Peter Stephenson 2003-04-03 09:55:40 +00:00
parent a78bff4398
commit c34176365e
6 changed files with 191 additions and 44 deletions

View File

@ -1,3 +1,12 @@
2003-04-03 Peter Stephenson <pws@csr.com>
* c.f. 18431: acconfig.h, aczsh.m4, zshconfig.ac,
Doc/Zsh/builtins.yo, Src/Builtins/rlimits.c: Attempt
to resolve the raging RLIIMT_* problems. Use configure tests
for all values which need testing. Use RLIMIT_AS for
`ulimit -v' if RLIMIT_VMEM is not present and make sure the value
gets multiplied by 1024.
2003-04-01 Peter Stephenson <pws@csr.com>
* 18418: Test/A01grammar.ztst, Test/D04parameter.ztst:

View File

@ -1357,7 +1357,8 @@ sitem(tt(-n))(open file descriptors.)
sitem(tt(-s))(K-bytes on the size of the stack.)
sitem(tt(-t))(CPU seconds to be used.)
sitem(tt(-u))(processes available to the user.)
sitem(tt(-v))(K-bytes on the size of virtual memory.)
sitem(tt(-v))(K-bytes on the size of virtual memory. On some systems this
refers to the limit called `address space'.)
endsitem()
)
findex(umask)

View File

@ -175,38 +175,38 @@ printulimit(int lim, int hard, int head)
break;
/* If RLIMIT_VMEM and RLIMIT_RSS are defined and equal, avoid *
* duplicate case statement. Observed on QNX Neutrino 6.1.0. */
# if defined(RLIMIT_RSS) && (!defined(RLIMIT_VMEM) || RLIMIT_VMEM != RLIMIT_RSS)
# if defined(HAVE_RLIMIT_RSS) && !defined(RLIMIT_VMEM_IS_RSS)
case RLIMIT_RSS:
if (head)
printf("resident set size (kbytes) ");
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
# endif /* RLIMIT_RSS */
# ifdef RLIMIT_MEMLOCK
# endif /* HAVE_RLIMIT_RSS */
# ifdef HAVE_RLIMIT_MEMLOCK
case RLIMIT_MEMLOCK:
if (head)
printf("locked-in-memory size (kb) ");
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
# endif /* RLIMIT_MEMLOCK */
# ifdef RLIMIT_NPROC
# endif /* HAVE_RLIMIT_MEMLOCK */
# ifdef HAVE_RLIMIT_NPROC
case RLIMIT_NPROC:
if (head)
printf("processes ");
break;
# endif /* RLIMIT_NPROC */
# ifdef RLIMIT_NOFILE
# endif /* HAVE_RLIMIT_NPROC */
# ifdef HAVE_RLIMIT_NOFILE
case RLIMIT_NOFILE:
if (head)
printf("file descriptors ");
break;
# endif /* RLIMIT_NOFILE */
# ifdef RLIMIT_VMEM
# endif /* HAVE_RLIMIT_NOFILE */
# ifdef HAVE_RLIMIT_VMEM
case RLIMIT_VMEM:
if (head)
# if defined(RLIMIT_RSS) && RLIMIT_VMEM == RLIMIT_RSS
# if defined(HAVE_RLIMIT_RSS) && defined(RLIMIT_VMEM_IS_RSS)
printf("memory size (kb) ");
# else
printf("virtual memory size (kb) ");
@ -214,55 +214,55 @@ printulimit(int lim, int hard, int head)
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
# endif /* RLIMIT_VMEM */
# if defined RLIMIT_AS && RLIMIT_AS != RLIMIT_VMEM
# endif /* HAVE_RLIMIT_VMEM */
# if defined HAVE_RLIMIT_AS && !defined(RLIMIT_VMEM_IS_AS)
case RLIMIT_AS:
if (head)
printf("address space (kb) ");
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
# endif /* RLIMIT_AS */
# ifdef RLIMIT_TCACHE
# endif /* HAVE_RLIMIT_AS */
# ifdef HAVE_RLIMIT_TCACHE
case RLIMIT_TCACHE:
if (head)
printf("cached threads ");
break;
# endif /* RLIMIT_TCACHE */
# ifdef RLIMIT_AIO_OPS
# endif /* HAVE_RLIMIT_TCACHE */
# ifdef HAVE_RLIMIT_AIO_OPS
case RLIMIT_AIO_OPS:
if (head)
printf("AIO operations ");
break;
# endif /* RLIMIT_AIO_OPS */
# ifdef RLIMIT_AIO_MEM
# endif /* HAVE_RLIMIT_AIO_OPS */
# ifdef HAVE_RLIMIT_AIO_MEM
case RLIMIT_AIO_MEM:
if (head)
printf("AIO locked-in-memory (kb) ");
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
# endif /* RLIMIT_AIO_MEM */
# ifdef RLIMIT_SBSIZE
# endif /* HAVE_RLIMIT_AIO_MEM */
# ifdef HAVE_RLIMIT_SBSIZE
case RLIMIT_SBSIZE:
if (head)
printf("socket buffer size (kb) ");
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
# endif /* RLIMIT_SBSIZE */
# ifdef RLIMIT_PTHREAD
# endif /* HAVE_RLIMIT_SBSIZE */
# ifdef HAVE_RLIMIT_PTHREAD
case RLIMIT_PTHREAD:
if (head)
printf("threads per process ");
break;
# endif /* RLIMIT_PTHREAD */
# ifdef RLIMIT_LOCKS
# endif /* HAVE_RLIMIT_PTHREAD */
# ifdef HAVE_RLIMIT_LOCKS
case RLIMIT_LOCKS:
if (head)
printf("file locks ");
break;
# endif /* RLIMIT_LOCKS */
# endif /* HAVE_RLIMIT_LOCKS */
}
/* display the limit */
if (limit == RLIM_INFINITY)
@ -509,31 +509,35 @@ bin_ulimit(char *name, char **argv, Options ops, int func)
case 'c':
res = RLIMIT_CORE;
break;
# ifdef RLIMIT_RSS
# ifdef HAVE_RLIMIT_RSS
case 'm':
res = RLIMIT_RSS;
break;
# endif /* RLIMIT_RSS */
# ifdef RLIMIT_MEMLOCK
# endif /* HAVE_RLIMIT_RSS */
# ifdef HAVE_RLIMIT_MEMLOCK
case 'l':
res = RLIMIT_MEMLOCK;
break;
# endif /* RLIMIT_MEMLOCK */
# ifdef RLIMIT_NOFILE
# endif /* HAVE_RLIMIT_MEMLOCK */
# ifdef HAVE_RLIMIT_NOFILE
case 'n':
res = RLIMIT_NOFILE;
break;
# endif /* RLIMIT_NOFILE */
# ifdef RLIMIT_NPROC
# endif /* HAVE_RLIMIT_NOFILE */
# ifdef HAVE_RLIMIT_NPROC
case 'u':
res = RLIMIT_NPROC;
break;
# endif /* RLIMIT_NPROC */
# ifdef RLIMIT_VMEM
# endif /* HAVE_RLIMIT_NPROC */
# if defined(HAVE_RLIMIT_VMEM) || defined(HAVE_RLIMIT_AS)
case 'v':
# ifdef HAVE_RLIMIT_VMEM
res = RLIMIT_VMEM;
# else
res = RLIMIT_AS;
# endif
break;
# endif /* RLIMIT_VMEM */
# endif /* HAVE_RLIMIT_VMEM */
default:
/* unrecognised limit */
zwarnnam(name, "bad option: -%c", NULL, *options);
@ -571,20 +575,24 @@ bin_ulimit(char *name, char **argv, Options ops, int func)
break;
case RLIMIT_DATA:
case RLIMIT_STACK:
# ifdef RLIMIT_RSS
# ifdef HAVE_RLIMIT_RSS
case RLIMIT_RSS:
# endif /* RLIMIT_RSS */
# ifdef RLIMIT_MEMLOCK
# endif /* HAVE_RLIMIT_RSS */
# ifdef HAVE_RLIMIT_MEMLOCK
case RLIMIT_MEMLOCK:
# endif /* RLIMIT_MEMLOCK */
# endif /* HAVE_RLIMIT_MEMLOCK */
/* If RLIMIT_VMEM and RLIMIT_RSS are defined and equal, avoid *
* duplicate case statement. Observed on QNX Neutrino 6.1.0. */
# if defined(RLIMIT_VMEM) && (!defined(RLIMIT_RSS) || RLIMIT_RSS != RLIMIT_VMEM)
# if defined(HAVE_RLIMIT_VMEM) && !defined(RLIMIT_VMEM_IS_RSS)
case RLIMIT_VMEM:
# endif /* RLIMIT_VMEM */
# ifdef RLIMIT_AIO_MEM
# endif /* HAVE_RLIMIT_VMEM */
/* ditto RLIMIT_VMEM and RLIMIT_AS */
# if defined(HAVE_RLIMIT_AS) && !defined(RLIMIT_VMEM_IS_AS)
case RLIMIT_AS:
# endif /* HAVE_RLIMIT_AS */
# ifdef HAVE_RLIMIT_AIO_MEM
case RLIMIT_AIO_MEM:
# endif /* RLIMIT_AIO_MEM */
# endif /* HAVE_RLIMIT_AIO_MEM */
limit *= 1024;
break;
}

View File

@ -238,6 +238,48 @@
/* Define to the type used in struct rlimit */
#undef rlim_t
/* Define to 1 if RLIMIT_AIO_MEM is present (whether or not as a macro) */
#undef HAVE_RLIMIT_AIO_MEM
/* Define to 1 if RLIMIT_AIO_OPS is present (whether or not as a macro) */
#undef HAVE_RLIMIT_AIO_OPS
/* Define to 1 if RLIMIT_AS is present (whether or not as a macro) */
#undef HAVE_RLIMIT_AS
/* Define to 1 if RLIMIT_LOCKS is present (whether or not as a macro) */
#undef HAVE_RLIMIT_LOCKS
/* Define to 1 if RLIMIT_MEMLOCK is present (whether or not as a macro) */
#undef HAVE_RLIMIT_MEMLOCK
/* Define to 1 if RLIMIT_NPROC is present (whether or not as a macro) */
#undef HAVE_RLIMIT_NPROC
/* Define to 1 if RLIMIT_NOFILE is present (whether or not as a macro) */
#undef HAVE_RLIMIT_NOFILE
/* Define to 1 if RLIMIT_PTHREAD is present (whether or not as a macro) */
#undef HAVE_RLIMIT_PTHREAD
/* Define to 1 if RLIMIT_RSS is present (whether or not as a macro) */
#undef HAVE_RLIMIT_RSS
/* Define to 1 if RLIMIT_SBSIZE is present (whether or not as a macro) */
#undef HAVE_RLIMIT_SBSIZE
/* Define to 1 if RLIMIT_TCACHE is present (whether or not as a macro) */
#undef HAVE_RLIMIT_TCACHE
/* Define to 1 if RLIMIT_VMEM is present (whether or not as a macro) */
#undef HAVE_RLIMIT_VMEM
/* Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal */
#undef RLIMIT_VMEM_IS_RSS
/* Define to 1 if RLIMIT_VMEM and RLIMIT_AS both exist and are equal */
#undef RLIMIT_VMEM_IS_AS
/* Define to 1 if /bin/sh does not interpret \ escape sequences */
#undef SH_USE_BSD_ECHO

View File

@ -710,3 +710,21 @@ AC_DEFUN([zsh_CHECK_SOCKLEN_T],[
AC_DEFINE_UNQUOTED([SOCKLEN_T], [$zsh_cv_type_socklen_t])]
)
dnl Check for limit $1 e.g. RLIMIT_RSS.
AC_DEFUN(zsh_LIMIT_PRESENT,
[AC_CACHE_CHECK([for limit $1],
zsh_cv_have_$1,
[AC_TRY_COMPILE([
#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/resource.h>],
[$1],
zsh_cv_have_$1=yes,
zsh_cv_have_$1=no)])
if test $zsh_cv_have_$1 = yes; then
AC_DEFINE(HAVE_$1)
fi])

View File

@ -1221,6 +1221,75 @@ if test $zsh_cv_type_rlim_t = no; then
AC_DEFINE_UNQUOTED(rlim_t, $DEFAULT_RLIM_T)
fi
dnl On some systems the RLIMIT_* don't evaluate to integers at compile time
dnl (they may be enums). In this case we are not able to do preprocessor
dnl comparisions and need our tests to determine what values exist and
dnl if there are clashing definitions.
zsh_LIMIT_PRESENT(RLIMIT_AIO_MEM)
zsh_LIMIT_PRESENT(RLIMIT_AIO_OPS)
zsh_LIMIT_PRESENT(RLIMIT_AS)
zsh_LIMIT_PRESENT(RLIMIT_LOCKS)
zsh_LIMIT_PRESENT(RLIMIT_MEMLOCK)
zsh_LIMIT_PRESENT(RLIMIT_NPROC)
zsh_LIMIT_PRESENT(RLIMIT_NOFILE)
zsh_LIMIT_PRESENT(RLIMIT_PTHREAD)
zsh_LIMIT_PRESENT(RLIMIT_RSS)
zsh_LIMIT_PRESENT(RLIMIT_SBSIZE)
zsh_LIMIT_PRESENT(RLIMIT_TCACHE)
zsh_LIMIT_PRESENT(RLIMIT_VMEM)
AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_RSS are the same,
zsh_cv_rlimit_vmem_is_rss,
[AC_TRY_RUN([
#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/resource.h>
int main()
{
int ret = 1;
#if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_RSS)
if (RLIMIT_RSS == RLIMIT_VMEM) ret = 0;
#endif
return ret;
}],
zsh_cv_rlimit_vmem_is_rss=yes,
zsh_cv_rlimit_vmem_is_rss=no,
zsh_cv_rlimit_vmem_is_rss=no)])
if test $zsh_cv_rlimit_vmem_is_rss = yes; then
AC_DEFINE(RLIMIT_VMEM_IS_RSS)
fi
AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_AS are the same,
zsh_cv_rlimit_vmem_is_as,
[AC_TRY_RUN([
#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/resource.h>
int main()
{
int ret = 1;
#if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_AS)
if (RLIMIT_AS == RLIMIT_VMEM) ret = 0;
#endif
return ret;
}],
zsh_cv_rlimit_vmem_is_as=yes,
zsh_cv_rlimit_vmem_is_as=no,
zsh_cv_rlimit_vmem_is_as=no)])
if test $zsh_cv_rlimit_vmem_is_as = yes; then
AC_DEFINE(RLIMIT_VMEM_IS_AS)
fi
dnl ----------------------------
dnl CHECK FOR /dev/fd FILESYSTEM
dnl ----------------------------