diff --git a/funcs.c b/funcs.c index 6bef544..cd3e6e7 100644 --- a/funcs.c +++ b/funcs.c @@ -25,7 +25,7 @@ #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 /* @@ -3118,6 +3118,49 @@ struct limits { static void print_ulimit(const struct limits *, 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 c_ulimit(const char **wp) { @@ -3141,18 +3184,12 @@ c_ulimit(const char **wp) #ifdef RLIMIT_MEMLOCK { "lockedmem(KiB)", RLIMIT_MEMLOCK, 1024, 'l' }, #endif -#ifdef RLIMIT_RSS - { "memory(KiB)", RLIMIT_RSS, 1024, 'm' }, -#endif #ifdef RLIMIT_NOFILE { "nofiles(descriptors)", RLIMIT_NOFILE, 1, 'n' }, #endif #ifdef RLIMIT_NPROC { "processes", RLIMIT_NPROC, 1, 'p' }, #endif -#ifdef RLIMIT_VMEM - { "vmemory(KiB)", RLIMIT_VMEM, 1024, 'v' }, -#endif #ifdef RLIMIT_SWAP { "swap(KiB)", RLIMIT_SWAP, 1024, 'w' }, #endif @@ -3164,6 +3201,43 @@ c_ulimit(const char **wp) #endif #ifdef RLIMIT_NOVMON { "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 { NULL, 0, 0, 0 } }; diff --git a/mksh.1 b/mksh.1 index 5c3acdb..5174821 100644 --- a/mksh.1 +++ b/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 $ .\"- .\" 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 .\" 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 .\" @@ -4541,7 +4541,7 @@ unless they are also given on the same command line. .Pp .It Xo .Ic ulimit -.Op Fl acdfHLlmnpSsTtVvw +.Op Fl aBCcdefHiLlMmnOPpqrSsTtVvw .Op Ar value .Xc Display or set process limits. @@ -4564,6 +4564,13 @@ limit. Display all limits; unless .Fl H 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 Impose a size limit of .Ar n @@ -4572,6 +4579,9 @@ blocks on the size of core dumps. Impose a size limit of .Ar n 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 Impose a size limit of .Ar n @@ -4579,12 +4589,19 @@ blocks on files written by the shell and its child processes (files of any size may be read). .It Fl H 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 Control flocks; documentation is missing. .It Fl l Ar n Impose a limit of .Ar n 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 Impose a limit of .Ar n @@ -4593,10 +4610,25 @@ kibibytes on the amount of physical memory used. Impose a limit of .Ar n 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 Impose a limit of .Ar n 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 Set the soft limit only (the default is to set both hard and soft limits). .It Fl s Ar n diff --git a/sh.h b/sh.h index 5f5198b..8f10ac4 100644 --- a/sh.h +++ b/sh.h @@ -150,7 +150,7 @@ #endif #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 #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) #endif -#if !defined(RLIMIT_VMEM) && defined(RLIMIT_AS) -#define RLIMIT_VMEM RLIMIT_AS -#endif - #if !defined(MAP_FAILED) /* XXX imake style */ # if defined(__linux)