summaryrefslogtreecommitdiffstats
path: root/man2/getrlimit.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/getrlimit.2')
-rw-r--r--man2/getrlimit.218
1 files changed, 9 insertions, 9 deletions
diff --git a/man2/getrlimit.2 b/man2/getrlimit.2
index 3b923ca2a..21f919fdc 100644
--- a/man2/getrlimit.2
+++ b/man2/getrlimit.2
@@ -792,44 +792,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