| Rev | Author | # | Line |
|---|---|---|---|
| 1 | perry | 1 | !!NAME |
| 2 | PerryLorier | 2 | getrlimit - get resource limits |
| 1 | perry | 3 | !!SYNOPSIS |
| 4 | |||
| 2 | PerryLorier | 5 | __#include <sys/time.h>__ |
| 6 | __#include <sys/resource.h>__ | ||
| 7 | __#include <unistd.h>__ | ||
| 1 | perry | 8 | |
| 2 | PerryLorier | 9 | __int getrlimit (int__ ''resource''__, struct rlimit *__''rlim''__);__ |
| 1 | perry | 10 | !!DESCRIPTION |
| 2 | PerryLorier | 11 | getrlimit(2) get resource limits respectively. ''resource'' should be one of: |
| 1 | perry | 12 | |
| 2 | PerryLorier | 13 | __RLIMIT_CPU__ /* CPU time in seconds */ |
| 14 | __RLIMIT_FSIZE__ /* Maximum filesize */ | ||
| 15 | __RLIMIT_DATA__ /* max data size */ | ||
| 16 | __RLIMIT_STACK__ /* max stack size */ | ||
| 17 | __RLIMIT_CORE__ /* max core file size */ | ||
| 18 | __RLIMIT_RSS__ /* max resident set size */ | ||
| 19 | __RLIMIT_NPROC__ /* max number of processes */ | ||
| 20 | __RLIMIT_NOFILE__ /* max number of open files */ | ||
| 21 | __RLIMIT_MEMLOCK__ /* max locked-in-memory address space*/ | ||
| 22 | __RLIMIT_AS__ /* address space (virtual memory) limit */ | ||
| 1 | perry | 23 | |
| 2 | PerryLorier | 24 | A resource may unlimited if you set the limit to __RLIM_INFINITY__. __RLIMIT_OFILE__ is the BSD name for __RLIMIT_NOFILE__. |
| 1 | perry | 25 | |
| 2 | PerryLorier | 26 | The __rlimit__ structure is defined as follows: |
| 1 | perry | 27 | |
| 2 | PerryLorier | 28 | struct rlimit { |
| 29 | rlim_t rlim_cur; | ||
| 30 | rlim_t rlim_max; | ||
| 31 | }; | ||
| 1 | perry | 32 | |
| 2 | PerryLorier | 33 | __getrusage__ returns the current resource usages, for a ''who'' of either __RUSAGE_SELF__ or __RUSAGE_CHILDREN.__ |
| 1 | perry | 34 | |
| 2 | PerryLorier | 35 | struct rusage { |
| 36 | struct timeval ru_utime; /* user time used */ | ||
| 37 | struct timeval ru_stime; /* system time used */ | ||
| 38 | long ru_maxrss; /* maximum resident set size */ | ||
| 39 | long ru_ixrss; /* integral shared memory size */ | ||
| 40 | long ru_idrss; /* integral unshared data size */ | ||
| 41 | long ru_isrss; /* integral unshared stack size */ | ||
| 42 | long ru_minflt; /* page reclaims */ | ||
| 43 | long ru_majflt; /* page faults */ | ||
| 44 | long ru_nswap; /* swaps */ | ||
| 45 | long ru_inblock; /* block input operations */ | ||
| 46 | long ru_oublock; /* block output operations */ | ||
| 47 | long ru_msgsnd; /* messages sent */ | ||
| 48 | long ru_msgrcv; /* messages received */ | ||
| 49 | long ru_nsignals; /* signals received */ | ||
| 50 | long ru_nvcsw; /* voluntary context switches */ | ||
| 51 | long ru_nivcsw; /* involuntary context switches */ | ||
| 52 | }; | ||
| 53 | !!RETURN VALUE | ||
| 1 | perry | 54 | |
| 55 | |||
| 2 | PerryLorier | 56 | On success, zero is returned. On error, -1 is returned, and ''errno'' is set appropriately. |
| 1 | perry | 57 | |
| 58 | !!ERRORS | ||
| 2 | PerryLorier | 59 | ;[EFAULT]: ''rlim'' points outside the accessible address space. |
| 3 | PerryLorier | 60 | ;[EINVAL]: getrlimit(2) is called with a bad ''resource'' |
| 1 | perry | 61 | !!CONFORMING TO |
| 62 | SVr4, BSD 4.3 | ||
| 63 | !!NOTE | ||
| 2 | PerryLorier | 64 | Including ''<sys/time.h>'' is not required these days, but increases portability. (Indeed, ''struct timeval'' is defined in ''<sys/time.h>''.) |
| 1 | perry | 65 | |
| 2 | PerryLorier | 66 | The above struct was taken from BSD 4.3 Reno. Not all fields are meaningful under Linux. Right now (Linux 2.4) only the fields __ru_utime__, __ru_stime__, __ru_minflt__, __ru_majflt__, and __ru_nswap__ are maintained. |
| 1 | perry | 67 | |
| 68 | !!SEE ALSO | ||
| 69 | quotactl(2), ulimit(3) |
lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 7 times)