Files
oldlinux-files/Linux-0.98/Yggdrasil-0.98.3/usr/man/man2/getrlimit.2
2024-02-19 00:21:16 -05:00

119 lines
2.4 KiB
Groff

.TH GETRLIMIT 2
.UC 4
.SH NAME
getrlimit, getrusage, setrlimit \- get/set resource limits and usage
.SH SYNOPSIS
.nf
.B #include <sys/resource.h>
.B #include <unistd.h>
.B int getrlimit (int resource, struct rlimit *rlim);
.B int getrusage (int who, struct rusage *usage);
.B int setrlimit (int resource, const struct rlimit *rlim);
.fi
.SH DESCRIPTION
.B getrlimit()
and
.B setrlimit()
get and set resource limits respectively.
.I resource should be one of :
.PP
.B RLIMIT_CPU
/* CPU time in ms */
.br
.B RLIMIT_FSIZE
/* Maximum filesize */
.br
.B RLIMIT_DATA
/* max data size */
.br
.B RLIMIT_STACK
/* max stack size */
.br
.B RLIMIT_CORE
/* max core file size */
.br
.B RLIMIT_RSS
/* max resident set size */
.PP
The following are not yet implemented :
.PP
.B RLIMIT_MEMLOCK
/* max locked-in-memory address space*/
.br
.B RLIMIT_NPROC
/* max number of processes */
.br
.B RLIMIT_OFILE
/* max number of open files */
.PP
A resource may unlimited if you set the limit to
.B RLIM_INFINITY.
.PP
The
.B rlimit
structure is defined as follows :
.PP
.nf
struct rlimit {
.in 21
int rlim_cur;
int rlim_max;
};
.in 10
.fi
.PP
.B getrusage()
returns the current resource usages, for a
.I who
of either
.B RUSAGE_SELF
or
.B RUSAGE_CHILDREN.
.PP
.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 " */
};
.fi
.PP
0 is returned on success, a negative value for error.
.SH ERRORS
.B -EINVAL
is returned if
.B getrlimit(), setrlimit()
is called with a bad
.I resource,
or
.B getrusage()
is called with a bad
.I who.
.PP
.B -EPERM
is returned if a non-superuser tries to call
.B setrlimit()
.SH FILES
linux/kernel/sys.c
.br
/usr/include/linux/sys.h
.br
/usr/include/unistd.h
.br
/usr/include/sys/resource.h
.SH SEE ALSO
ulimit(2)