.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (c) 1992 Drew Eckhardt, March 28, 1992 .\" .\" 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 .\" .\" 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. .\" .\" 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 .\" Modified Fri Jul 23 21:18:14 1993 by Rik Faith .\" Modified Jan 13, 1996 by Arnt Gulbrandsen .\" Modified Jan 22, 1996 by aeb, following a remark by .\" Tigran Aivazian .\" Modified Apr 14, 1996 by aeb, following a remark by .\" Robert Bihlmeyer .\" Modified Tue Oct 22 17:34:42 1996 by Eric S. Raymond .\" .TH GETRLIMIT 2 "23 July 1993" "Linux" "Linux Programmer's Manual" .SH NAME getrlimit, getrusage, setrlimit \- get/set resource limits and usage .SH SYNOPSIS .B #include .br .B #include .br .B #include .sp .BI "int getrlimit (int " resource ", struct rlimit *" rlim ); .br .BI "int getrusage (int " who ", struct rusage *" usage ); .br .BI "int setrlimit (int " resource ", const struct rlimit *" rlim ); .SH DESCRIPTION .B getrlimit and .B setrlimit get and set resource limits respectively. .I resource should be one of: .PP \fBRLIMIT_CPU\fP /* CPU time in seconds */ .br \fBRLIMIT_FSIZE\fP /* Maximum filesize */ .br \fBRLIMIT_DATA\fP /* max data size */ .br \fBRLIMIT_STACK\fP /* max stack size */ .br \fBRLIMIT_CORE\fP /* max core file size */ .br \fBRLIMIT_RSS\fP /* max resident set size */ .br \fBRLIMIT_NPROC\fP /* max number of processes */ .br \fBRLIMIT_NOFILE\fP /* max number of open files */ .br \fBRLIMIT_MEMLOCK\fP /* max locked-in-memory address space*/ .PP A resource may unlimited if you set the limit to .BR RLIM_INFINITY ". " RLIMIT_OFILE is the BSD name for .BR RLIMIT_NOFILE . .PP The .B rlimit structure is defined as follows : .PP .in +0.5i .nf struct rlimit { int rlim_cur; int rlim_max; }; .fi .in -0.5i .PP .B getrusage returns the current resource usages, for a \fIwho\fP of either .B RUSAGE_SELF or .B RUSAGE_CHILDREN. .PP .in +0.5i .nf struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ long ru_maxrss; /* maximum resident set size */ long ru_ixrss; /* integral shared memory size */ long ru_idrss; /* integral unshared data size */ long ru_isrss; /* integral unshared stack size */ long ru_minflt; /* page reclaims */ long ru_majflt; /* page faults */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary context switches */ }; .fi .in -0.5i .SH "RETURN VALUE" On success, zero is returned. On error, \-1 is returned, and .I errno is set appropriately. .SH ERRORS .TP .B EINVAL .BR getrlimit " or " setrlimit is called with a bad \fIresource\fP, or \fBgetrusage\fP is called with a bad \fIwho\fP. .TP .B EPERM A non-superuser tries to use \fBsetrlimit()\fP to increase the soft or hard limit above the current hard limit, or a superuser tries to increase RLIMIT_NOFILE above the current kernel maximum. .SH "CONFORMING TO" SVr4, BSD 4.3 .SH "SEE ALSO" .BR ulimit "(2), " quotactl (2)