-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprlimits.c
More file actions
60 lines (50 loc) · 1.13 KB
/
prlimits.c
File metadata and controls
60 lines (50 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
#define PRLIMIT(name) printlimit(#name, name)
void
error(const char* reason)
{
perror(reason);
exit(EXIT_FAILURE);
}
void
printlimit(const char* name, int resource)
{
struct rlimit lim;
if (getrlimit(resource, &lim) == -1)
error("getrlimit");
printf("%-20s ", name);
if (lim.rlim_cur == RLIM_INFINITY)
printf("(infinite) ");
else
printf("%ld ", lim.rlim_cur);
if (lim.rlim_max == RLIM_INFINITY)
printf("(infinite)");
else
printf("%ld", lim.rlim_max);
putchar('\n');
}
int
main()
{
PRLIMIT(RLIMIT_CORE);
PRLIMIT(RLIMIT_CPU);
PRLIMIT(RLIMIT_DATA);
PRLIMIT(RLIMIT_FSIZE);
PRLIMIT(RLIMIT_NOFILE);
PRLIMIT(RLIMIT_STACK);
PRLIMIT(RLIMIT_AS);
PRLIMIT(RLIMIT_LOCKS);
PRLIMIT(RLIMIT_MEMLOCK);
PRLIMIT(RLIMIT_MSGQUEUE);
PRLIMIT(RLIMIT_NICE);
PRLIMIT(RLIMIT_NOFILE);
PRLIMIT(RLIMIT_NPROC);
PRLIMIT(RLIMIT_RSS);
PRLIMIT(RLIMIT_RTPRIO);
PRLIMIT(RLIMIT_RTTIME);
PRLIMIT(RLIMIT_SIGPENDING);
PRLIMIT(RLIMIT_STACK);
return 0;
}