2004-11-03 13:51:07 +00:00
|
|
|
|
.\" Hey Emacs! This file is -*- nroff -*- source.
|
|
|
|
|
.\"
|
|
|
|
|
.\" Copyright (c) 1992 Drew Eckhardt, March 28, 1992
|
2010-11-15 06:43:18 +00:00
|
|
|
|
.\" and Copyright (c) 2002, 2004, 2005, 2008, 2010 Michael Kerrisk
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.\"
|
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
|
.\" preserved on all copies.
|
|
|
|
|
.\"
|
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
|
.\"
|
|
|
|
|
.\" Modified by Michael Haardt <michael@moria.de>
|
|
|
|
|
.\" Modified 1993-07-23 by Rik Faith <faith@cs.unc.edu>
|
|
|
|
|
.\" Modified 1996-01-13 by Arnt Gulbrandsen <agulbra@troll.no>
|
|
|
|
|
.\" Modified 1996-01-22 by aeb, following a remark by
|
|
|
|
|
.\" Tigran Aivazian <tigran@sco.com>
|
|
|
|
|
.\" Modified 1996-04-14 by aeb, following a remark by
|
|
|
|
|
.\" Robert Bihlmeyer <robbe@orcus.ping.at>
|
|
|
|
|
.\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
|
|
|
|
|
.\" Modified 2001-05-04 by aeb, following a remark by
|
|
|
|
|
.\" H<>vard Lygre <hklygre@online.no>
|
2007-09-20 06:52:22 +00:00
|
|
|
|
.\" Modified 2001-04-17 by Michael Kerrisk <mtk.manpages@gmail.com>
|
|
|
|
|
.\" Modified 2002-06-13 by Michael Kerrisk <mtk.manpages@gmail.com>
|
accept.2, execve.2, futimesat.2, getresuid.2, getrlimit.2, madvise.2, mq_getsetattr.2, msgctl.2, nice.2, open.2, poll.2, setresuid.2, shmctl.2, sigaction.2, times.2, utimensat.2, __setfpucw.3, atoi.3, endian.3, err.3, euidaccess.3, fenv.3, fopencookie.3, fpurge.3, getgrouplist.3, getutmp.3, j0.3, lgamma.3, netlink.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_cleanup_push_defer_np.3, pthread_getattr_np.3, pthread_kill_other_threads_np.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, pthread_yield.3, random_r.3, readdir.3, rtnetlink.3, scanf.3, setenv.3, significand.3, sigsetops.3, strerror.3, strstr.3, sysv_signal.3, termios.3, timegm.3, unlocked_stdio.3, y0.3, locale.5, bootparam.7, feature_test_macros.7, ip.7, locale.7, pthreads.7, rtld-audit.7, nscd.8: Global fix: s/non-standard/nonstandard/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:37:52 +00:00
|
|
|
|
.\" Added note on nonstandard behavior when SIGCHLD is ignored.
|
2007-09-20 06:52:22 +00:00
|
|
|
|
.\" Modified 2002-07-09 by Michael Kerrisk <mtk.manpages@gmail.com>
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.\" Enhanced descriptions of 'resource' values
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.\" Modified 2003-11-28 by aeb, added RLIMIT_CORE
|
|
|
|
|
.\" Modified 2004-03-26 by aeb, added RLIMIT_AS
|
2007-09-20 06:52:22 +00:00
|
|
|
|
.\" Modified 2004-06-16 by Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.\" Added notes on CAP_SYS_RESOURCE
|
|
|
|
|
.\"
|
2007-04-12 22:42:49 +00:00
|
|
|
|
.\" 2004-11-16 -- mtk: the getrlimit.2 page, which formally included
|
2004-11-16 16:57:47 +00:00
|
|
|
|
.\" coverage of getrusage(2), has been split, so that the latter
|
|
|
|
|
.\" is now covered in its own getrusage.2.
|
|
|
|
|
.\"
|
|
|
|
|
.\" Modified 2004-11-16, mtk: A few other minor changes
|
2004-12-01 15:19:22 +00:00
|
|
|
|
.\" Modified 2004-11-23, mtk
|
|
|
|
|
.\" Added notes on RLIMIT_MEMLOCK, RLIMIT_NPROC, and RLIMIT_RSS
|
|
|
|
|
.\" to "CONFORMING TO"
|
|
|
|
|
.\" Modified 2004-11-25, mtk
|
|
|
|
|
.\" Rewrote discussion on RLIMIT_MEMLOCK to incorporate kernel
|
|
|
|
|
.\" 2.6.9 changes.
|
|
|
|
|
.\" Added note on RLIMIT_CPU error in older kernels
|
2005-07-28 14:38:36 +00:00
|
|
|
|
.\" 2004-11-03, mtk, Added RLIMIT_SIGPENDING
|
2005-07-13 12:51:27 +00:00
|
|
|
|
.\" 2005-07-13, mtk, documented RLIMIT_MSGQUEUE limit.
|
2005-07-28 14:38:36 +00:00
|
|
|
|
.\" 2005-07-28, mtk, Added descriptions of RLIMIT_NICE and RLIMIT_RTPRIO
|
2008-06-11 22:04:51 +00:00
|
|
|
|
.\" 2008-05-07, mtk / Peter Zijlstra, Added description of RLIMIT_RTTIME
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.\" 2010-11-06, mtk: Added documentation of prlimit()
|
2004-11-16 16:57:47 +00:00
|
|
|
|
.\"
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.TH GETRLIMIT 2 2010-11-06 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.SH NAME
|
2010-11-07 14:23:12 +00:00
|
|
|
|
getrlimit, setrlimit, prlimit \- get/set resource limits
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.SH SYNOPSIS
|
|
|
|
|
.B #include <sys/time.h>
|
|
|
|
|
.br
|
|
|
|
|
.B #include <sys/resource.h>
|
|
|
|
|
.sp
|
|
|
|
|
.BI "int getrlimit(int " resource ", struct rlimit *" rlim );
|
|
|
|
|
.br
|
|
|
|
|
.BI "int setrlimit(int " resource ", const struct rlimit *" rlim );
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.sp
|
|
|
|
|
.BI "int prlimit(pid_t " pid ", int " resource \
|
|
|
|
|
", const struct rlimit *" new_limit ,
|
|
|
|
|
.br
|
|
|
|
|
.BI " struct rlimit *" old_limit );
|
|
|
|
|
.sp
|
|
|
|
|
.in -4n
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
|
|
|
.BR feature_test_macros (7)):
|
|
|
|
|
.in
|
|
|
|
|
.sp
|
|
|
|
|
.BR prlimit ():
|
|
|
|
|
_GNU_SOURCE
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.SH DESCRIPTION
|
2010-11-07 14:23:12 +00:00
|
|
|
|
The
|
2004-11-16 16:57:47 +00:00
|
|
|
|
.BR getrlimit ()
|
2004-11-03 13:51:07 +00:00
|
|
|
|
and
|
2004-11-16 16:57:47 +00:00
|
|
|
|
.BR setrlimit ()
|
2010-11-07 14:40:12 +00:00
|
|
|
|
system calls get and set resource limits respectively.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
Each resource has an associated soft and hard limit, as defined by the
|
2005-11-02 13:55:25 +00:00
|
|
|
|
.I rlimit
|
2010-11-07 14:43:23 +00:00
|
|
|
|
structure:
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.PP
|
2007-12-19 05:53:30 +00:00
|
|
|
|
.in +4n
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.nf
|
|
|
|
|
struct rlimit {
|
2004-11-16 16:57:47 +00:00
|
|
|
|
rlim_t rlim_cur; /* Soft limit */
|
|
|
|
|
rlim_t rlim_max; /* Hard limit (ceiling for rlim_cur) */
|
2004-11-03 13:51:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
.fi
|
2007-12-19 05:53:30 +00:00
|
|
|
|
.in
|
2004-11-03 13:51:07 +00:00
|
|
|
|
The soft limit is the value that the kernel enforces for the
|
|
|
|
|
corresponding resource.
|
|
|
|
|
The hard limit acts as a ceiling for the soft limit:
|
2007-04-12 22:42:49 +00:00
|
|
|
|
an unprivileged process may only set its soft limit to a value in the
|
2004-11-03 13:51:07 +00:00
|
|
|
|
range from 0 up to the hard limit, and (irreversibly) lower its hard limit.
|
|
|
|
|
A privileged process (under Linux: one with the
|
|
|
|
|
.B CAP_SYS_RESOURCE
|
|
|
|
|
capability) may make arbitrary changes to either limit value.
|
|
|
|
|
.PP
|
|
|
|
|
The value
|
|
|
|
|
.B RLIM_INFINITY
|
|
|
|
|
denotes no limit on a resource (both in the structure returned by
|
|
|
|
|
.BR getrlimit ()
|
|
|
|
|
and in the structure passed to
|
|
|
|
|
.BR setrlimit ()).
|
|
|
|
|
.PP
|
2010-11-07 14:40:12 +00:00
|
|
|
|
The
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.I resource
|
2010-11-07 14:40:12 +00:00
|
|
|
|
argument must be one of:
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
|
|
|
|
.B RLIMIT_AS
|
|
|
|
|
The maximum size of the process's virtual memory (address space) in bytes.
|
|
|
|
|
.\" since 2.0.27 / 2.1.12
|
|
|
|
|
This limit affects calls to
|
|
|
|
|
.BR brk (2),
|
|
|
|
|
.BR mmap (2)
|
|
|
|
|
and
|
|
|
|
|
.BR mremap (2),
|
|
|
|
|
which fail with the error
|
|
|
|
|
.B ENOMEM
|
2007-04-24 16:44:51 +00:00
|
|
|
|
upon exceeding this limit.
|
|
|
|
|
Also automatic stack expansion will fail
|
2004-11-16 16:57:47 +00:00
|
|
|
|
(and generate a
|
|
|
|
|
.B SIGSEGV
|
|
|
|
|
that kills the process if no alternate stack
|
|
|
|
|
has been made available via
|
|
|
|
|
.BR sigaltstack (2)).
|
2005-06-16 10:32:30 +00:00
|
|
|
|
Since the value is a \fIlong\fP, on machines with a 32-bit \fIlong\fP
|
2004-11-03 13:51:07 +00:00
|
|
|
|
either this limit is at most 2 GiB, or this resource is unlimited.
|
|
|
|
|
.TP
|
|
|
|
|
.B RLIMIT_CORE
|
|
|
|
|
Maximum size of
|
|
|
|
|
.I core
|
2007-04-24 16:44:51 +00:00
|
|
|
|
file.
|
|
|
|
|
When 0 no core dump files are created.
|
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt.2, gettimeofday.2, intro.2, ioctl_list.2, ioperm.2, mlock.2, pivot_root.2, poll.2, prctl.2, ptrace.2, sched_setscheduler.2, select_tut.2, semget.2, sigaltstack.2, signalfd.2, sysctl.2, timer_settime.2, timerfd_create.2, wait.2, CPU_SET.3, argz_add.3, assert_perror.3, atexit.3, backtrace.3, bcmp.3, clearenv.3, ctime.3, dl_iterate_phdr.3, dlopen.3, ecvt.3, errno.3, error.3, ether_aton.3, exit.3, fenv.3, ferror.3, finite.3, flockfile.3, fnmatch.3, fpathconf.3, fpclassify.3, ftime.3, ftok.3, ftw.3, fwide.3, getaddrinfo.3, gethostbyname.3, getlogin.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getrpcent.3, getservent.3, glob.3, hsearch.3, inet.3, isalpha.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, longjmp.3, lsearch.3, malloc.3, matherr.3, mblen.3, mbsinit.3, mbtowc.3, on_exit.3, printf.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_equal.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, ptsname.3, putenv.3, putgrent.3, raise.3, rcmd.3, regex.3, rexec.3, rpc.3, rpmatch.3, rtnetlink.3, scandir.3, sem_init.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, signbit.3, stdio_ext.3, strtod.3, strtol.3, strtoul.3, system.3, termios.3, timeradd.3, tzset.3, ualarm.3, wctomb.3, xdr.3, st.4, tty_ioctl.4, core.5, elf.5, proc.5, bootparam.7, capabilities.7, icmp.7, ip.7, ipv6.7, math_error.7, mdoc.samples.7, mq_overview.7, pthreads.7, raw.7, regex.7, socket.7, tcp.7, tzselect.8: Global fix: s/non-zero/nonzero/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:40:55 +00:00
|
|
|
|
When nonzero, larger dumps are truncated to this size.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
|
|
|
|
.B RLIMIT_CPU
|
|
|
|
|
CPU time limit in seconds.
|
|
|
|
|
When the process reaches the soft limit, it is sent a
|
|
|
|
|
.B SIGXCPU
|
|
|
|
|
signal.
|
|
|
|
|
The default action for this signal is to terminate the process.
|
|
|
|
|
However, the signal can be caught, and the handler can return control to
|
|
|
|
|
the main program.
|
|
|
|
|
If the process continues to consume CPU time, it will be sent
|
|
|
|
|
.B SIGXCPU
|
|
|
|
|
once per second until the hard limit is reached, at which time
|
|
|
|
|
it is sent
|
|
|
|
|
.BR SIGKILL .
|
2007-06-08 09:56:56 +00:00
|
|
|
|
(This latter point describes Linux 2.2 through 2.6 behavior.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
Implementations vary in how they treat processes which continue to
|
|
|
|
|
consume CPU time after reaching the soft limit.
|
|
|
|
|
Portable applications that need to catch this signal should
|
|
|
|
|
perform an orderly termination upon first receipt of
|
2004-12-03 16:06:22 +00:00
|
|
|
|
.BR SIGXCPU .)
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
|
|
|
|
.B RLIMIT_DATA
|
|
|
|
|
The maximum size of the process's data segment (initialized data,
|
|
|
|
|
uninitialized data, and heap).
|
|
|
|
|
This limit affects calls to
|
2007-05-11 23:07:02 +00:00
|
|
|
|
.BR brk (2)
|
2007-04-12 22:42:49 +00:00
|
|
|
|
and
|
2007-05-11 23:07:02 +00:00
|
|
|
|
.BR sbrk (2),
|
2004-11-03 13:51:07 +00:00
|
|
|
|
which fail with the error
|
|
|
|
|
.B ENOMEM
|
|
|
|
|
upon encountering the soft limit of this resource.
|
|
|
|
|
.TP
|
|
|
|
|
.B RLIMIT_FSIZE
|
|
|
|
|
The maximum size of files that the process may create.
|
|
|
|
|
Attempts to extend a file beyond this limit result in delivery of a
|
|
|
|
|
.B SIGXFSZ
|
|
|
|
|
signal.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
By default, this signal terminates a process, but a process can
|
|
|
|
|
catch this signal instead, in which case the relevant system call (e.g.,
|
2007-06-15 21:44:10 +00:00
|
|
|
|
.BR write (2),
|
2007-05-11 23:07:02 +00:00
|
|
|
|
.BR truncate (2))
|
2004-11-03 13:51:07 +00:00
|
|
|
|
fails with the error
|
|
|
|
|
.BR EFBIG .
|
|
|
|
|
.TP
|
2005-07-13 12:51:27 +00:00
|
|
|
|
.BR RLIMIT_LOCKS " (Early Linux 2.4 only)"
|
|
|
|
|
.\" to be precise: Linux 2.4.0-test9; no longer in 2.4.25 / 2.5.65
|
2004-11-03 13:51:07 +00:00
|
|
|
|
A limit on the combined number of
|
2007-05-11 23:07:02 +00:00
|
|
|
|
.BR flock (2)
|
2007-04-12 22:42:49 +00:00
|
|
|
|
locks and
|
2007-05-11 23:07:02 +00:00
|
|
|
|
.BR fcntl (2)
|
2004-11-03 13:51:07 +00:00
|
|
|
|
leases that this process may establish.
|
|
|
|
|
.TP
|
|
|
|
|
.B RLIMIT_MEMLOCK
|
2004-12-01 15:19:22 +00:00
|
|
|
|
The maximum number of bytes of memory that may be locked
|
|
|
|
|
into RAM.
|
|
|
|
|
In effect this limit is rounded down to the nearest multiple
|
|
|
|
|
of the system page size.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
This limit affects
|
2005-10-19 07:29:28 +00:00
|
|
|
|
.BR mlock (2)
|
2007-04-12 22:42:49 +00:00
|
|
|
|
and
|
2005-10-19 07:29:28 +00:00
|
|
|
|
.BR mlockall (2)
|
2004-12-01 15:19:22 +00:00
|
|
|
|
and the
|
|
|
|
|
.BR mmap (2)
|
|
|
|
|
.B MAP_LOCKED
|
|
|
|
|
operation.
|
|
|
|
|
Since Linux 2.6.9 it also affects the
|
|
|
|
|
.BR shmctl (2)
|
|
|
|
|
.B SHM_LOCK
|
2007-04-12 22:42:49 +00:00
|
|
|
|
operation, where it sets a maximum on the total bytes in
|
2004-12-01 15:19:22 +00:00
|
|
|
|
shared memory segments (see
|
|
|
|
|
.BR shmget (2))
|
|
|
|
|
that may be locked by the real user ID of the calling process.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
The
|
2004-12-01 15:19:22 +00:00
|
|
|
|
.BR shmctl (2)
|
|
|
|
|
.B SHM_LOCK
|
|
|
|
|
locks are accounted for separately from the per-process memory
|
2007-04-12 22:42:49 +00:00
|
|
|
|
locks established by
|
|
|
|
|
.BR mlock (2),
|
2005-10-19 07:29:28 +00:00
|
|
|
|
.BR mlockall (2),
|
2004-12-01 15:19:22 +00:00
|
|
|
|
and
|
|
|
|
|
.BR mmap (2)
|
|
|
|
|
.BR MAP_LOCKED ;
|
|
|
|
|
a process can lock bytes up to this limit in each of these
|
2004-12-03 16:06:22 +00:00
|
|
|
|
two categories.
|
2004-12-01 15:19:22 +00:00
|
|
|
|
In Linux kernels before 2.6.9, this limit controlled the amount of
|
|
|
|
|
memory that could be locked by a privileged process.
|
|
|
|
|
Since Linux 2.6.9, no limits are placed on the amount of memory
|
|
|
|
|
that a privileged process may lock, and this limit instead governs
|
|
|
|
|
the amount of memory that an unprivileged process may lock.
|
2005-07-13 12:51:27 +00:00
|
|
|
|
.TP
|
|
|
|
|
.BR RLIMIT_MSGQUEUE " (Since Linux 2.6.8)"
|
|
|
|
|
Specifies the limit on the number of bytes that can be allocated
|
|
|
|
|
for POSIX message queues for the real user ID of the calling process.
|
|
|
|
|
This limit is enforced for
|
|
|
|
|
.BR mq_open (3).
|
|
|
|
|
Each message queue that the user creates counts (until it is removed)
|
|
|
|
|
against this limit according to the formula:
|
|
|
|
|
.nf
|
|
|
|
|
|
|
|
|
|
bytes = attr.mq_maxmsg * sizeof(struct msg_msg *) +
|
2005-10-28 13:32:01 +00:00
|
|
|
|
attr.mq_maxmsg * attr.mq_msgsize
|
2005-07-13 12:51:27 +00:00
|
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
|
.fi
|
|
|
|
|
where
|
2005-07-13 12:51:27 +00:00
|
|
|
|
.I attr
|
2007-04-12 22:42:49 +00:00
|
|
|
|
is the
|
2005-07-13 12:51:27 +00:00
|
|
|
|
.I mq_attr
|
|
|
|
|
structure specified as the fourth argument to
|
2007-05-11 23:07:02 +00:00
|
|
|
|
.BR mq_open (3).
|
2005-07-13 12:51:27 +00:00
|
|
|
|
|
|
|
|
|
The first addend in the formula, which includes
|
|
|
|
|
.I "sizeof(struct msg_msg *)"
|
2007-12-24 17:31:35 +00:00
|
|
|
|
(4 bytes on Linux/i386), ensures that the user cannot
|
2005-07-13 12:51:27 +00:00
|
|
|
|
create an unlimited number of zero-length messages (such messages
|
|
|
|
|
nevertheless each consume some system memory for bookkeeping overhead).
|
2005-09-19 14:57:05 +00:00
|
|
|
|
.TP
|
2008-05-07 13:33:52 +00:00
|
|
|
|
.BR RLIMIT_NICE " (since Linux 2.6.12, but see BUGS below)"
|
2005-09-20 17:43:58 +00:00
|
|
|
|
Specifies a ceiling to which the process's nice value can be raised using
|
2005-09-19 14:57:05 +00:00
|
|
|
|
.BR setpriority (2)
|
|
|
|
|
or
|
|
|
|
|
.BR nice (2).
|
|
|
|
|
The actual ceiling for the nice value is calculated as
|
|
|
|
|
.IR "20\ \-\ rlim_cur" .
|
2005-09-20 17:43:58 +00:00
|
|
|
|
(This strangeness occurs because negative numbers cannot be specified
|
|
|
|
|
as resource limit values, since they typically have special meanings.
|
2007-06-22 17:16:20 +00:00
|
|
|
|
For example,
|
|
|
|
|
.B RLIM_INFINITY
|
|
|
|
|
typically is the same as \-1.)
|
2005-07-28 14:38:36 +00:00
|
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.B RLIMIT_NOFILE
|
|
|
|
|
Specifies a value one greater than the maximum file descriptor number
|
|
|
|
|
that can be opened by this process.
|
|
|
|
|
Attempts
|
2007-05-11 23:07:02 +00:00
|
|
|
|
.RB ( open (2),
|
|
|
|
|
.BR pipe (2),
|
|
|
|
|
.BR dup (2),
|
2005-10-28 13:32:01 +00:00
|
|
|
|
etc.)
|
2004-11-03 13:51:07 +00:00
|
|
|
|
to exceed this limit yield the error
|
|
|
|
|
.BR EMFILE .
|
2008-10-05 03:42:32 +00:00
|
|
|
|
(Historically, this limit was named
|
|
|
|
|
.B RLIMIT_OFILE
|
|
|
|
|
on BSD.)
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
|
|
|
|
.B RLIMIT_NPROC
|
2007-04-12 22:42:49 +00:00
|
|
|
|
The maximum number of processes (or, more precisely on Linux, threads)
|
2006-12-01 03:49:20 +00:00
|
|
|
|
that can be created for the real user ID of the calling process.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
Upon encountering this limit,
|
2007-05-11 23:07:02 +00:00
|
|
|
|
.BR fork (2)
|
2004-11-03 13:51:07 +00:00
|
|
|
|
fails with the error
|
|
|
|
|
.BR EAGAIN .
|
|
|
|
|
.TP
|
|
|
|
|
.B RLIMIT_RSS
|
|
|
|
|
Specifies the limit (in pages) of the process's resident set
|
|
|
|
|
(the number of virtual pages resident in RAM).
|
2005-07-13 13:05:56 +00:00
|
|
|
|
This limit only has effect in Linux 2.4.x, x < 30, and there only
|
2004-11-03 13:51:07 +00:00
|
|
|
|
affects calls to
|
2007-05-11 23:07:02 +00:00
|
|
|
|
.BR madvise (2)
|
2004-11-03 13:51:07 +00:00
|
|
|
|
specifying
|
2005-07-13 12:51:27 +00:00
|
|
|
|
.BR MADV_WILLNEED .
|
|
|
|
|
.\" As at kernel 2.6.12, this limit still does nothing in 2.6 though
|
2007-04-12 22:42:49 +00:00
|
|
|
|
.\" talk of making it do something has surfaced from time to time in LKML
|
2005-07-13 13:05:56 +00:00
|
|
|
|
.\" -- MTK, Jul 05
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
2005-07-28 14:38:36 +00:00
|
|
|
|
.BR RLIMIT_RTPRIO " (Since Linux 2.6.12, but see BUGS)"
|
2007-04-12 22:42:49 +00:00
|
|
|
|
Specifies a ceiling on the real-time priority that may be set for
|
2005-09-20 17:43:58 +00:00
|
|
|
|
this process using
|
2005-07-28 14:38:36 +00:00
|
|
|
|
.BR sched_setscheduler (2)
|
|
|
|
|
and
|
|
|
|
|
.BR sched_setparam (2).
|
|
|
|
|
.TP
|
2008-06-11 22:04:51 +00:00
|
|
|
|
.BR RLIMIT_RTTIME " (Since Linux 2.6.25)"
|
2010-09-12 06:40:54 +00:00
|
|
|
|
Specifies a limit (in microseconds)
|
|
|
|
|
on the amount of CPU time that a process scheduled
|
2008-06-11 22:04:51 +00:00
|
|
|
|
under a real-time scheduling policy may consume without making a blocking
|
|
|
|
|
system call.
|
|
|
|
|
For the purpose of this limit,
|
|
|
|
|
each time a process makes a blocking system call,
|
|
|
|
|
the count of its consumed CPU time is reset to zero.
|
|
|
|
|
The CPU time count is not reset if the process continues trying to
|
|
|
|
|
use the CPU but is preempted, its time slice expires, or it calls
|
|
|
|
|
.BR sched_yield (2).
|
|
|
|
|
|
|
|
|
|
Upon reaching the soft limit, the process is sent a
|
|
|
|
|
.B SIGXCPU
|
|
|
|
|
signal.
|
|
|
|
|
If the process catches or ignores this signal and
|
|
|
|
|
continues consuming CPU time, then
|
|
|
|
|
.B SIGXCPU
|
|
|
|
|
will be generated once each second until the hard limit is reached,
|
|
|
|
|
at which point the process is sent a
|
|
|
|
|
.B SIGKILL
|
|
|
|
|
signal.
|
|
|
|
|
|
|
|
|
|
The intended use of this limit is to stop a runaway
|
|
|
|
|
real-time process from locking up the system.
|
|
|
|
|
.TP
|
2005-07-13 12:51:27 +00:00
|
|
|
|
.BR RLIMIT_SIGPENDING " (Since Linux 2.6.8)"
|
2004-12-07 17:57:48 +00:00
|
|
|
|
Specifies the limit on the number of signals
|
2004-12-03 16:06:22 +00:00
|
|
|
|
that may be queued for the real user ID of the calling process.
|
2004-12-07 17:57:48 +00:00
|
|
|
|
Both standard and real-time signals are counted for the purpose of
|
|
|
|
|
checking this limit.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
However, the limit is only enforced for
|
2004-12-07 17:57:48 +00:00
|
|
|
|
.BR sigqueue (2);
|
|
|
|
|
it is always possible to use
|
|
|
|
|
.BR kill (2)
|
|
|
|
|
to queue one instance of any of the signals that are not already
|
|
|
|
|
queued to the process.
|
2004-12-03 16:06:22 +00:00
|
|
|
|
.\" This replaces the /proc/sys/kernel/rtsig-max system-wide limit
|
|
|
|
|
.\" that was present in kernels <= 2.6.7. MTK Dec 04
|
|
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.B RLIMIT_STACK
|
|
|
|
|
The maximum size of the process stack, in bytes.
|
|
|
|
|
Upon reaching this limit, a
|
|
|
|
|
.B SIGSEGV
|
|
|
|
|
signal is generated.
|
|
|
|
|
To handle this signal, a process must employ an alternate signal stack
|
|
|
|
|
.RB ( sigaltstack (2)).
|
2008-10-05 04:24:36 +00:00
|
|
|
|
|
|
|
|
|
Since Linux 2.6.23,
|
|
|
|
|
this limit also determines the amount of space used for the process's
|
|
|
|
|
command-line arguments and environment variables; for details, see
|
|
|
|
|
.BR execve (2).
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.SS prlimit()
|
|
|
|
|
.\" commit c022a0acad534fd5f5d5f17280f6d4d135e74e81
|
|
|
|
|
.\" Author: Jiri Slaby <jslaby@suse.cz>
|
|
|
|
|
.\" Date: Tue May 4 18:03:50 2010 +0200
|
|
|
|
|
The Linux-specific
|
|
|
|
|
.BR prlimit ()
|
|
|
|
|
system call combines and extends the functionality of
|
|
|
|
|
.BR setrlimit ()
|
|
|
|
|
and
|
|
|
|
|
.BR getrlimit ().
|
|
|
|
|
It can be used to both set and get the resource limits of an arbitrary process.
|
|
|
|
|
|
|
|
|
|
The
|
|
|
|
|
.I resource
|
|
|
|
|
argument has the same meaning as for
|
|
|
|
|
.BR setrlimit ()
|
|
|
|
|
and
|
|
|
|
|
.BR getrlimit ().
|
|
|
|
|
|
|
|
|
|
If the
|
|
|
|
|
.IR new_limit
|
|
|
|
|
argument is a not NULL, then the
|
|
|
|
|
.I rlimit
|
|
|
|
|
structure to which it points is used to set new values for
|
|
|
|
|
the soft and hard limits for
|
|
|
|
|
.IR resource .
|
|
|
|
|
If the
|
|
|
|
|
.IR old_limit
|
|
|
|
|
argument is a not NULL, then a successful call to
|
|
|
|
|
.BR prlimit ()
|
|
|
|
|
places the previous soft and hard limits for
|
|
|
|
|
.I resource
|
2010-11-12 05:16:40 +00:00
|
|
|
|
in the
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.I rlimit
|
|
|
|
|
structure pointed to by
|
|
|
|
|
.IR old_limit .
|
|
|
|
|
|
|
|
|
|
The
|
|
|
|
|
.I pid
|
|
|
|
|
argument specifies the ID of the process on which the call is to operate.
|
|
|
|
|
If
|
|
|
|
|
.I pid
|
|
|
|
|
is 0, then the call applies to the calling process.
|
|
|
|
|
To set or get the resources of a process other than itself,
|
|
|
|
|
the caller must have the
|
|
|
|
|
.B CAP_SYS_RESOURCE
|
|
|
|
|
capability, or the
|
|
|
|
|
real, effective, and saved set user IDs of the target process
|
|
|
|
|
must match the real user ID of the caller
|
|
|
|
|
.I and
|
|
|
|
|
the real, effective, and saved set group IDs of the target process
|
|
|
|
|
must match the real group ID of the caller.
|
|
|
|
|
.\" FIXME this permission check is strange
|
|
|
|
|
.\" Asked about this on LKML, 7 Nov 2010
|
|
|
|
|
.\" "Inconsistent credential checking in prlimit() syscall"
|
|
|
|
|
.SH RETURN VALUE
|
|
|
|
|
On success, these system calls return 0.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
On error, \-1 is returned, and
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.I errno
|
|
|
|
|
is set appropriately.
|
|
|
|
|
.SH ERRORS
|
|
|
|
|
.TP
|
|
|
|
|
.B EFAULT
|
2010-11-07 14:23:12 +00:00
|
|
|
|
A pointer argument points to a location
|
|
|
|
|
outside the accessible address space.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
|
|
|
|
.B EINVAL
|
2010-11-07 14:23:12 +00:00
|
|
|
|
The value specified in
|
2004-11-16 16:57:47 +00:00
|
|
|
|
.I resource
|
2005-10-24 15:26:31 +00:00
|
|
|
|
is not valid;
|
|
|
|
|
or, for
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.BR setrlimit ()
|
|
|
|
|
or
|
|
|
|
|
.BR prlimit ():
|
2007-12-22 16:40:46 +00:00
|
|
|
|
.I rlim\->rlim_cur
|
2005-10-24 15:26:31 +00:00
|
|
|
|
was greater than
|
2007-12-22 16:40:46 +00:00
|
|
|
|
.IR rlim\->rlim_max .
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
|
|
|
|
.B EPERM
|
2010-11-07 14:23:12 +00:00
|
|
|
|
An unprivileged process tried to raise the hard limit; the
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.B CAP_SYS_RESOURCE
|
|
|
|
|
capability is required to do this.
|
2010-11-07 14:23:12 +00:00
|
|
|
|
Or, the the caller tried to increase the hard
|
2007-06-22 17:16:20 +00:00
|
|
|
|
.B RLIMIT_NOFILE
|
2010-11-07 14:23:12 +00:00
|
|
|
|
limit above the current kernel maximum
|
2007-06-22 19:42:52 +00:00
|
|
|
|
.RB ( NR_OPEN ).
|
2010-11-07 14:23:12 +00:00
|
|
|
|
Or, the calling process did not have permission to set limits
|
|
|
|
|
for the process specified by
|
|
|
|
|
.IR pid .
|
|
|
|
|
.TP
|
|
|
|
|
.B ESRCH
|
|
|
|
|
Could not find a process with the ID specified in
|
|
|
|
|
.IR pid .
|
|
|
|
|
.SH VERSIONS
|
|
|
|
|
.BR The
|
|
|
|
|
.BR prlimit ()
|
|
|
|
|
system call is available since Linux 2.6.36.
|
|
|
|
|
Library support is available since glibc 2.13.
|
2007-05-18 16:06:42 +00:00
|
|
|
|
.SH CONFORMING TO
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.BR getrlimit (),
|
|
|
|
|
.BR setrlimit ():
|
2007-05-18 16:06:42 +00:00
|
|
|
|
SVr4, 4.3BSD, POSIX.1-2001.
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.br
|
|
|
|
|
.BR prlimit ():
|
|
|
|
|
Linux-specific.
|
|
|
|
|
|
2007-09-20 16:26:31 +00:00
|
|
|
|
.B RLIMIT_MEMLOCK
|
2007-05-18 16:06:42 +00:00
|
|
|
|
and
|
2007-09-20 16:26:31 +00:00
|
|
|
|
.B RLIMIT_NPROC
|
2007-05-18 16:06:42 +00:00
|
|
|
|
derive from BSD and are not specified in POSIX.1-2001;
|
|
|
|
|
they are present on the BSDs and Linux, but on few other implementations.
|
2007-09-20 16:26:31 +00:00
|
|
|
|
.B RLIMIT_RSS
|
2007-05-18 16:06:42 +00:00
|
|
|
|
derives from BSD and is not specified in POSIX.1-2001;
|
|
|
|
|
it is nevertheless present on most implementations.
|
|
|
|
|
.BR RLIMIT_MSGQUEUE ,
|
|
|
|
|
.BR RLIMIT_NICE ,
|
|
|
|
|
.BR RLIMIT_RTPRIO ,
|
2008-06-11 22:04:51 +00:00
|
|
|
|
.BR RLIMIT_RTTIME ,
|
2007-05-18 16:06:42 +00:00
|
|
|
|
and
|
|
|
|
|
.B RLIMIT_SIGPENDING
|
2007-12-25 21:28:09 +00:00
|
|
|
|
are Linux-specific.
|
2007-05-18 16:06:42 +00:00
|
|
|
|
.SH NOTES
|
|
|
|
|
A child process created via
|
|
|
|
|
.BR fork (2)
|
2008-08-26 04:11:43 +00:00
|
|
|
|
inherits its parent's resource limits.
|
2007-05-18 16:06:42 +00:00
|
|
|
|
Resource limits are preserved across
|
|
|
|
|
.BR execve (2).
|
2008-08-26 04:19:07 +00:00
|
|
|
|
|
|
|
|
|
One can set the resource limits of the shell using the built-in
|
|
|
|
|
.IR ulimit
|
|
|
|
|
command
|
|
|
|
|
.RI ( limit
|
|
|
|
|
in
|
|
|
|
|
.BR csh (1)).
|
|
|
|
|
The shell's resource limits are inherited by the processes that
|
|
|
|
|
it creates to execute commands.
|
2010-09-26 04:59:41 +00:00
|
|
|
|
|
|
|
|
|
Ancient systems provided a
|
|
|
|
|
.BR vlimit ()
|
|
|
|
|
function with a similar purpose to
|
|
|
|
|
.BR setrlimit ().
|
|
|
|
|
For backward compatibility, glibc also provides
|
|
|
|
|
.BR vlimit ().
|
|
|
|
|
All new applications should be written using
|
|
|
|
|
.BR setrlimit ().
|
2004-12-01 15:19:22 +00:00
|
|
|
|
.SH BUGS
|
2010-11-07 14:23:12 +00:00
|
|
|
|
.\" FIXME prlimit() does not suffer
|
|
|
|
|
.\" https://bugzilla.kernel.org/show_bug.cgi?id=5042
|
|
|
|
|
.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=12201
|
2004-12-01 15:19:22 +00:00
|
|
|
|
In older Linux kernels, the
|
|
|
|
|
.B SIGXCPU
|
|
|
|
|
and
|
|
|
|
|
.B SIGKILL
|
|
|
|
|
signals delivered when a process encountered the soft and hard
|
2004-12-13 06:58:38 +00:00
|
|
|
|
.B RLIMIT_CPU
|
2004-12-01 15:19:22 +00:00
|
|
|
|
limits were delivered one (CPU) second later than they should have been.
|
|
|
|
|
This was fixed in kernel 2.6.8.
|
2005-07-28 14:38:36 +00:00
|
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
|
In 2.6.x kernels before 2.6.17, a
|
|
|
|
|
.B RLIMIT_CPU
|
|
|
|
|
limit of 0 is wrongly treated as "no limit" (like
|
2006-04-04 04:12:36 +00:00
|
|
|
|
.BR RLIM_INFINITY ).
|
2008-05-07 13:33:52 +00:00
|
|
|
|
Since Linux 2.6.17, setting a limit of 0 does have an effect,
|
2006-04-04 04:12:36 +00:00
|
|
|
|
but is actually treated as a limit of 1 second.
|
2006-07-11 04:19:49 +00:00
|
|
|
|
.\" see http://marc.theaimsgroup.com/?l=linux-kernel&m=114008066530167&w=2
|
2006-04-04 04:12:36 +00:00
|
|
|
|
|
2005-07-28 14:38:36 +00:00
|
|
|
|
A kernel bug means that
|
|
|
|
|
.B RLIMIT_RTPRIO
|
|
|
|
|
does not work in kernel 2.6.12; the problem is fixed in kernel 2.6.13.
|
2005-09-20 06:52:49 +00:00
|
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
|
In kernel 2.6.12, there was an off-by-one mismatch
|
2005-10-19 14:48:35 +00:00
|
|
|
|
between the priority ranges returned by
|
|
|
|
|
.BR getpriority (2)
|
|
|
|
|
and
|
2005-09-20 06:52:49 +00:00
|
|
|
|
.BR RLIMIT_NICE .
|
2010-11-15 06:42:39 +00:00
|
|
|
|
This had the effect that the actual ceiling for the nice value
|
2005-09-20 06:52:49 +00:00
|
|
|
|
was calculated as
|
|
|
|
|
.IR "19\ \-\ rlim_cur" .
|
2005-09-20 17:43:58 +00:00
|
|
|
|
This was fixed in kernel 2.6.13.
|
2005-09-20 06:52:49 +00:00
|
|
|
|
.\" see http://marc.theaimsgroup.com/?l=linux-kernel&m=112256338703880&w=2
|
2005-10-24 15:26:31 +00:00
|
|
|
|
|
|
|
|
|
Kernels before 2.4.22 did not diagnose the error
|
|
|
|
|
.B EINVAL
|
2007-04-12 22:42:49 +00:00
|
|
|
|
for
|
2005-10-24 15:26:31 +00:00
|
|
|
|
.BR setrlimit ()
|
|
|
|
|
when
|
2007-12-22 16:40:46 +00:00
|
|
|
|
.I rlim\->rlim_cur
|
2005-10-24 15:26:31 +00:00
|
|
|
|
was greater than
|
2007-12-22 16:40:46 +00:00
|
|
|
|
.IR rlim\->rlim_max .
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.SH "SEE ALSO"
|
|
|
|
|
.BR dup (2),
|
|
|
|
|
.BR fcntl (2),
|
|
|
|
|
.BR fork (2),
|
2004-11-16 16:57:47 +00:00
|
|
|
|
.BR getrusage (2),
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.BR mlock (2),
|
|
|
|
|
.BR mmap (2),
|
|
|
|
|
.BR open (2),
|
|
|
|
|
.BR quotactl (2),
|
|
|
|
|
.BR sbrk (2),
|
2004-12-01 15:19:22 +00:00
|
|
|
|
.BR shmctl (2),
|
2004-12-03 16:06:22 +00:00
|
|
|
|
.BR sigqueue (2),
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.BR malloc (3),
|
|
|
|
|
.BR ulimit (3),
|
2006-03-31 07:10:17 +00:00
|
|
|
|
.BR core (5),
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.BR capabilities (7),
|
|
|
|
|
.BR signal (7)
|