diff options
Diffstat (limited to 'man2/getrlimit.2')
-rw-r--r-- | man2/getrlimit.2 | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/man2/getrlimit.2 b/man2/getrlimit.2 index cb69a04fc..afc2c229c 100644 --- a/man2/getrlimit.2 +++ b/man2/getrlimit.2 @@ -42,7 +42,7 @@ .\" 2008-05-07, mtk / Peter Zijlstra, Added description of RLIMIT_RTTIME .\" 2010-11-06, mtk: Added documentation of prlimit() .\" -.TH getrlimit 2 2023-02-05 "Linux man-pages 6.03" +.TH getrlimit 2 2023-07-20 "Linux man-pages 6.05.01" .SH NAME getrlimit, setrlimit, prlimit \- get/set resource limits .SH LIBRARY @@ -540,37 +540,32 @@ for the process specified by .B ESRCH Could not find a process with the ID specified in .IR pid . -.SH VERSIONS -The -.BR prlimit () -system call is available since Linux 2.6.36. -Library support is available since glibc 2.13. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). -.ad l -.nh .TS allbox; lbx lb lb l l l. Interface Attribute Value T{ +.na +.nh .BR getrlimit (), .BR setrlimit (), .BR prlimit () T} Thread safety MT-Safe .TE -.hy -.ad .sp 1 .SH STANDARDS -.BR getrlimit (), -.BR setrlimit (): -POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. -.PP -.BR prlimit (): -Linux-specific. +.TP +.BR getrlimit () +.TQ +.BR setrlimit () +POSIX.1-2008. +.TP +.BR prlimit () +Linux. .PP .B RLIMIT_MEMLOCK and @@ -580,13 +575,23 @@ they are present on the BSDs and Linux, but on few other implementations. .B RLIMIT_RSS derives from BSD and is not specified in POSIX.1; it is nevertheless present on most implementations. -.BR RLIMIT_MSGQUEUE , +.BR \%RLIMIT_MSGQUEUE , .BR RLIMIT_NICE , .BR RLIMIT_RTPRIO , .BR RLIMIT_RTTIME , and -.B RLIMIT_SIGPENDING +.B \%RLIMIT_SIGPENDING are Linux-specific. +.SH HISTORY +.TP +.BR getrlimit () +.TQ +.BR setrlimit () +POSIX.1-2001, SVr4, 4.3BSD. +.TP +.BR prlimit () +Linux 2.6.36, +glibc 2.13. .SH NOTES A child process created via .BR fork (2) @@ -738,9 +743,9 @@ the kernel represents resource limits on 32-bit platforms as .IR "unsigned long" . However, a 32-bit data type is not wide enough. .\" https://bugzilla.kernel.org/show_bug.cgi?id=5042 -.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=12201 +.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=12201 The most pertinent limit here is -.BR RLIMIT_FSIZE , +.BR \%RLIMIT_FSIZE , which specifies the maximum size to which a file can grow: to be useful, this limit must be represented using a type that is as wide as the type used to @@ -762,13 +767,13 @@ In other words, the requested resource limit setting was silently ignored. Since glibc 2.13, .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=12201 glibc works around the limitations of the -.BR getrlimit () +.BR \%getrlimit () and .BR setrlimit () system calls by implementing .BR setrlimit () and -.BR getrlimit () +.BR \%getrlimit () as wrapper functions that call .BR prlimit (). .SH EXAMPLES @@ -785,44 +790,44 @@ The program below demonstrates the use of #include <stdlib.h> #include <sys/resource.h> #include <time.h> - +\& int main(int argc, char *argv[]) { pid_t pid; struct rlimit old, new; struct rlimit *newp; - +\& if (!(argc == 2 || argc == 4)) { fprintf(stderr, "Usage: %s <pid> [<new\-soft\-limit> " "<new\-hard\-limit>]\en", argv[0]); exit(EXIT_FAILURE); } - +\& pid = atoi(argv[1]); /* PID of target process */ - +\& newp = NULL; if (argc == 4) { new.rlim_cur = atoi(argv[2]); new.rlim_max = atoi(argv[3]); newp = &new; } - +\& /* Set CPU time limit of target process; retrieve and display previous limit */ - +\& if (prlimit(pid, RLIMIT_CPU, newp, &old) == \-1) err(EXIT_FAILURE, "prlimit\-1"); printf("Previous limits: soft=%jd; hard=%jd\en", (intmax_t) old.rlim_cur, (intmax_t) old.rlim_max); - +\& /* Retrieve and display new CPU time limit */ - +\& if (prlimit(pid, RLIMIT_CPU, NULL, &old) == \-1) err(EXIT_FAILURE, "prlimit\-2"); printf("New limits: soft=%jd; hard=%jd\en", (intmax_t) old.rlim_cur, (intmax_t) old.rlim_max); - +\& exit(EXIT_SUCCESS); } .EE |