rework ‘m’ and ‘v’ ulimits; add more (seen at zsh)
This commit is contained in:
parent
ab1af5bdaf
commit
98e43b0f7a
88
funcs.c
88
funcs.c
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.152 2010/03/14 11:58:32 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.153 2010/03/27 16:51:37 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
|
@ -3118,6 +3118,49 @@ struct limits {
|
||||||
static void print_ulimit(const struct limits *, int);
|
static void print_ulimit(const struct limits *, int);
|
||||||
static int set_ulimit(const struct limits *, const char *, int);
|
static int set_ulimit(const struct limits *, const char *, int);
|
||||||
|
|
||||||
|
/* Magic to divine the 'm' and 'v' limits */
|
||||||
|
|
||||||
|
#ifdef RLIMIT_AS
|
||||||
|
#if !defined(RLIMIT_VMEM) || (RLIMIT_VMEM == RLIMIT_AS) || \
|
||||||
|
!defined(RLIMIT_RSS) || (RLIMIT_VMEM == RLIMIT_RSS)
|
||||||
|
#define ULIMIT_V_IS_AS
|
||||||
|
#elif defined(RLIMIT_VMEM)
|
||||||
|
#if !defined(RLIMIT_RSS) || (RLIMIT_RSS == RLIMIT_AS)
|
||||||
|
#define ULIMIT_V_IS_AS
|
||||||
|
#else
|
||||||
|
#define ULIMIT_V_IS_VMEM
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RLIMIT_RSS
|
||||||
|
#ifdef ULIMIT_V_IS_VMEM
|
||||||
|
#define ULIMIT_M_IS_RSS
|
||||||
|
#elif defined(RLIMIT_VMEM) && (RLIMIT_VMEM == RLIMIT_RSS)
|
||||||
|
#define ULIMIT_M_IS_VMEM
|
||||||
|
#else
|
||||||
|
#define ULIMIT_M_IS_RSS
|
||||||
|
#endif
|
||||||
|
#if defined(ULIMIT_M_IS_RSS) && defined(RLIMIT_AS) && (RLIMIT_RSS == RLIMIT_AS)
|
||||||
|
#undef ULIMIT_M_IS_RSS
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(RLIMIT_AS) && !defined(ULIMIT_M_IS_VMEM) && defined(RLIMIT_VMEM)
|
||||||
|
#define ULIMIT_V_IS_VMEM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(ULIMIT_V_IS_VMEM) && defined(RLIMIT_VMEM) && \
|
||||||
|
(!defined(RLIMIT_RSS) || (defined(RLIMIT_AS) && (RLIMIT_RSS == RLIMIT_AS)))
|
||||||
|
#define ULIMIT_M_IS_VMEM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ULIMIT_M_IS_VMEM) && defined(RLIMIT_AS) && \
|
||||||
|
(RLIMIT_VMEM == RLIMIT_AS)
|
||||||
|
#undef ULIMIT_M_IS_VMEM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
c_ulimit(const char **wp)
|
c_ulimit(const char **wp)
|
||||||
{
|
{
|
||||||
|
@ -3141,18 +3184,12 @@ c_ulimit(const char **wp)
|
||||||
#ifdef RLIMIT_MEMLOCK
|
#ifdef RLIMIT_MEMLOCK
|
||||||
{ "lockedmem(KiB)", RLIMIT_MEMLOCK, 1024, 'l' },
|
{ "lockedmem(KiB)", RLIMIT_MEMLOCK, 1024, 'l' },
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_RSS
|
|
||||||
{ "memory(KiB)", RLIMIT_RSS, 1024, 'm' },
|
|
||||||
#endif
|
|
||||||
#ifdef RLIMIT_NOFILE
|
#ifdef RLIMIT_NOFILE
|
||||||
{ "nofiles(descriptors)", RLIMIT_NOFILE, 1, 'n' },
|
{ "nofiles(descriptors)", RLIMIT_NOFILE, 1, 'n' },
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_NPROC
|
#ifdef RLIMIT_NPROC
|
||||||
{ "processes", RLIMIT_NPROC, 1, 'p' },
|
{ "processes", RLIMIT_NPROC, 1, 'p' },
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_VMEM
|
|
||||||
{ "vmemory(KiB)", RLIMIT_VMEM, 1024, 'v' },
|
|
||||||
#endif
|
|
||||||
#ifdef RLIMIT_SWAP
|
#ifdef RLIMIT_SWAP
|
||||||
{ "swap(KiB)", RLIMIT_SWAP, 1024, 'w' },
|
{ "swap(KiB)", RLIMIT_SWAP, 1024, 'w' },
|
||||||
#endif
|
#endif
|
||||||
|
@ -3164,6 +3201,43 @@ c_ulimit(const char **wp)
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_NOVMON
|
#ifdef RLIMIT_NOVMON
|
||||||
{ "vnodemonitors", RLIMIT_NOVMON, 1, 'V' },
|
{ "vnodemonitors", RLIMIT_NOVMON, 1, 'V' },
|
||||||
|
#endif
|
||||||
|
#ifdef RLIMIT_SIGPENDING
|
||||||
|
{ "sigpending", RLIMIT_SIGPENDING, 1, 'i' },
|
||||||
|
#endif
|
||||||
|
#ifdef RLIMIT_MSGQUEUE
|
||||||
|
{ "msgqueue(bytes)", RLIMIT_MSGQUEUE, 1, 'q' },
|
||||||
|
#endif
|
||||||
|
#ifdef RLIMIT_AIO_MEM
|
||||||
|
{ "AIOlockedmem(KiB)", RLIMIT_AIO_MEM, 1024, 'M' },
|
||||||
|
#endif
|
||||||
|
#ifdef RLIMIT_AIO_OPS
|
||||||
|
{ "AIOoperations", RLIMIT_AIO_OPS, 1, 'O' },
|
||||||
|
#endif
|
||||||
|
#ifdef RLIMIT_TCACHE
|
||||||
|
{ "cachedthreads", RLIMIT_TCACHE, 1, 'C' },
|
||||||
|
#endif
|
||||||
|
#ifdef RLIMIT_SBSIZE
|
||||||
|
{ "sockbufsiz(KiB)", RLIMIT_SBSIZE, 1024, 'B' },
|
||||||
|
#endif
|
||||||
|
#ifdef RLIMIT_PTHREAD
|
||||||
|
{ "threadsperprocess", RLIMIT_PTHREAD, 1, 'P' },
|
||||||
|
#endif
|
||||||
|
#ifdef RLIMIT_NICE
|
||||||
|
{ "maxnice", RLIMIT_NICE, 1, 'e' },
|
||||||
|
#endif
|
||||||
|
#ifdef RLIMIT_RTPRIO
|
||||||
|
{ "maxrtprio", RLIMIT_RTPRIO, 1, 'r' },
|
||||||
|
#endif
|
||||||
|
#if defined(ULIMIT_M_IS_RSS)
|
||||||
|
{ "resident-set(KiB)", RLIMIT_RSS, 1024, 'm' },
|
||||||
|
#elif defined(ULIMIT_M_IS_VMEM)
|
||||||
|
{ "memory(KiB)", RLIMIT_VMEM, 1024, 'm' },
|
||||||
|
#endif
|
||||||
|
#if defined(ULIMIT_V_IS_VMEM)
|
||||||
|
{ "virtual-memory(KiB)", RLIMIT_VMEM, 1024, 'v' },
|
||||||
|
#elif defined(ULIMIT_V_IS_AS)
|
||||||
|
{ "address-space(KiB)", RLIMIT_AS, 1024, 'v' },
|
||||||
#endif
|
#endif
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
38
mksh.1
38
mksh.1
|
@ -1,4 +1,4 @@
|
||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.220 2010/03/15 18:14:40 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.221 2010/03/27 16:51:38 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.131 2010/02/26 03:32:39 william Exp $
|
.\" $OpenBSD: ksh.1,v 1.131 2010/02/26 03:32:39 william Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
.\" with -mandoc, it might implement .Mx itself, but we want to
|
.\" with -mandoc, it might implement .Mx itself, but we want to
|
||||||
.\" use our own definition. And .Dd must come *first*, always.
|
.\" use our own definition. And .Dd must come *first*, always.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: March 15 2010 $
|
.Dd $Mdocdate: March 27 2010 $
|
||||||
.\"
|
.\"
|
||||||
.\" Check which macro package we use
|
.\" Check which macro package we use
|
||||||
.\"
|
.\"
|
||||||
|
@ -4541,7 +4541,7 @@ unless they are also given on the same command line.
|
||||||
.Pp
|
.Pp
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic ulimit
|
.Ic ulimit
|
||||||
.Op Fl acdfHLlmnpSsTtVvw
|
.Op Fl aBCcdefHiLlMmnOPpqrSsTtVvw
|
||||||
.Op Ar value
|
.Op Ar value
|
||||||
.Xc
|
.Xc
|
||||||
Display or set process limits.
|
Display or set process limits.
|
||||||
|
@ -4564,6 +4564,13 @@ limit.
|
||||||
Display all limits; unless
|
Display all limits; unless
|
||||||
.Fl H
|
.Fl H
|
||||||
is used, soft limits are displayed.
|
is used, soft limits are displayed.
|
||||||
|
.It Fl B Ar n
|
||||||
|
Set the socket buffer size to
|
||||||
|
.Ar n
|
||||||
|
kibibytes.
|
||||||
|
.It Fl C Ar n
|
||||||
|
Set the number of cached threads to
|
||||||
|
.Ar n .
|
||||||
.It Fl c Ar n
|
.It Fl c Ar n
|
||||||
Impose a size limit of
|
Impose a size limit of
|
||||||
.Ar n
|
.Ar n
|
||||||
|
@ -4572,6 +4579,9 @@ blocks on the size of core dumps.
|
||||||
Impose a size limit of
|
Impose a size limit of
|
||||||
.Ar n
|
.Ar n
|
||||||
kibibytes on the size of the data area.
|
kibibytes on the size of the data area.
|
||||||
|
.It Fl e Ar n
|
||||||
|
Set the maximum niceness to
|
||||||
|
.Ar n .
|
||||||
.It Fl f Ar n
|
.It Fl f Ar n
|
||||||
Impose a size limit of
|
Impose a size limit of
|
||||||
.Ar n
|
.Ar n
|
||||||
|
@ -4579,12 +4589,19 @@ blocks on files written by the shell and its child processes (files of any
|
||||||
size may be read).
|
size may be read).
|
||||||
.It Fl H
|
.It Fl H
|
||||||
Set the hard limit only (the default is to set both hard and soft limits).
|
Set the hard limit only (the default is to set both hard and soft limits).
|
||||||
|
.It Fl i Ar n
|
||||||
|
Set the number of pending signals to
|
||||||
|
.Ar n .
|
||||||
.It Fl L Ar n
|
.It Fl L Ar n
|
||||||
Control flocks; documentation is missing.
|
Control flocks; documentation is missing.
|
||||||
.It Fl l Ar n
|
.It Fl l Ar n
|
||||||
Impose a limit of
|
Impose a limit of
|
||||||
.Ar n
|
.Ar n
|
||||||
kibibytes on the amount of locked (wired) physical memory.
|
kibibytes on the amount of locked (wired) physical memory.
|
||||||
|
.It Fl M Ar n
|
||||||
|
Set the AIO locked memory to
|
||||||
|
.Ar n
|
||||||
|
kibibytes.
|
||||||
.It Fl m Ar n
|
.It Fl m Ar n
|
||||||
Impose a limit of
|
Impose a limit of
|
||||||
.Ar n
|
.Ar n
|
||||||
|
@ -4593,10 +4610,25 @@ kibibytes on the amount of physical memory used.
|
||||||
Impose a limit of
|
Impose a limit of
|
||||||
.Ar n
|
.Ar n
|
||||||
file descriptors that can be open at once.
|
file descriptors that can be open at once.
|
||||||
|
.It Fl O Ar n
|
||||||
|
Set the number of AIO operations to
|
||||||
|
.Ar n .
|
||||||
|
.It Fl P Ar n
|
||||||
|
Limit the number of threads per process to
|
||||||
|
.Ar n .
|
||||||
.It Fl p Ar n
|
.It Fl p Ar n
|
||||||
Impose a limit of
|
Impose a limit of
|
||||||
.Ar n
|
.Ar n
|
||||||
processes that can be run by the user at any one time.
|
processes that can be run by the user at any one time.
|
||||||
|
.It Fl q Ar n
|
||||||
|
Limit the size of
|
||||||
|
.Px
|
||||||
|
message queues to
|
||||||
|
.Ar n
|
||||||
|
bytes.
|
||||||
|
.It Fl r Ar n
|
||||||
|
Set the maximum real-time priority to
|
||||||
|
.Ar n .
|
||||||
.It Fl S
|
.It Fl S
|
||||||
Set the soft limit only (the default is to set both hard and soft limits).
|
Set the soft limit only (the default is to set both hard and soft limits).
|
||||||
.It Fl s Ar n
|
.It Fl s Ar n
|
||||||
|
|
6
sh.h
6
sh.h
|
@ -150,7 +150,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.384 2010/03/14 11:58:33 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.385 2010/03/27 16:51:39 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R39 2010/03/14"
|
#define MKSH_VERSION "R39 2010/03/14"
|
||||||
|
|
||||||
|
@ -251,10 +251,6 @@ typedef int bool;
|
||||||
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
|
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(RLIMIT_VMEM) && defined(RLIMIT_AS)
|
|
||||||
#define RLIMIT_VMEM RLIMIT_AS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(MAP_FAILED)
|
#if !defined(MAP_FAILED)
|
||||||
/* XXX imake style */
|
/* XXX imake style */
|
||||||
# if defined(__linux)
|
# if defined(__linux)
|
||||||
|
|
Loading…
Reference in New Issue