Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | |||
8 | extern unsigned int _stklen; |
||
9 | extern struct rlimit __libc_limits[]; |
||
10 | |||
11 | static int rlimit_count = -1; |
||
12 | struct rlimit __libc_limits[RLIM_NLIMITS]; |
||
13 | |||
14 | static void |
||
15 | __limits_initialize (void) |
||
16 | { |
||
17 | int i; |
||
18 | |||
19 | /* set hard limit */ |
||
20 | __libc_limits[RLIMIT_CPU].rlim_max = RLIM_INFINITY; |
||
21 | __libc_limits[RLIMIT_FSIZE].rlim_max = RLIM_INFINITY; |
||
22 | __libc_limits[RLIMIT_DATA].rlim_max = RLIM_INFINITY; |
||
23 | __libc_limits[RLIMIT_STACK].rlim_max = (long) _stklen; |
||
24 | __libc_limits[RLIMIT_CORE].rlim_max = RLIM_INFINITY; |
||
25 | __libc_limits[RLIMIT_RSS].rlim_max = RLIM_INFINITY; |
||
26 | __libc_limits[RLIMIT_MEMLOCK].rlim_max = RLIM_INFINITY; |
||
27 | __libc_limits[RLIMIT_NPROC].rlim_max = RLIM_INFINITY; |
||
28 | __libc_limits[RLIMIT_NOFILE].rlim_max = sysconf (_SC_OPEN_MAX); |
||
29 | |||
30 | /* copy all hard limit to soft limit */ |
||
31 | for (i = 0; i < RLIM_NLIMITS; i++) |
||
32 | __libc_limits[i].rlim_cur = __libc_limits[i].rlim_max; |
||
33 | } |
||
34 | |||
35 | int |
||
36 | getrlimit (int rltype, struct rlimit *rlimitp) |
||
37 | { |
||
38 | /* check argument range */ |
||
39 | if (rltype < 0 || rltype >= RLIM_NLIMITS || rlimitp == NULL) |
||
40 | { |
||
41 | errno = EINVAL; |
||
42 | return -1; |
||
43 | } |
||
44 | |||
45 | /* initialize */ |
||
46 | if (rlimit_count != __bss_count) |
||
47 | { |
||
48 | rlimit_count = __bss_count; |
||
49 | __limits_initialize (); |
||
50 | } |
||
51 | |||
52 | /* copy limit value */ |
||
53 | *rlimitp = __libc_limits[rltype]; |
||
54 | |||
55 | return 0; |
||
56 | }>> |