resource.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /* Bit values & structures for resource limits. Linux/SPARC version.
  2. Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2004, 2005
  3. Free Software Foundation, Inc.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _SYS_RESOURCE_H
  16. # error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
  17. #endif
  18. #include <bits/types.h>
  19. /* Transmute defines to enumerations. The macro re-definitions are
  20. necessary because some programs want to test for operating system
  21. features with #ifdef RUSAGE_SELF. In ISO C the reflexive
  22. definition is a no-op. */
  23. /* Kinds of resource limit. */
  24. enum __rlimit_resource
  25. {
  26. /* Per-process CPU limit, in seconds. */
  27. RLIMIT_CPU = 0,
  28. #define RLIMIT_CPU RLIMIT_CPU
  29. /* Largest file that can be created, in bytes. */
  30. RLIMIT_FSIZE = 1,
  31. #define RLIMIT_FSIZE RLIMIT_FSIZE
  32. /* Maximum size of data segment, in bytes. */
  33. RLIMIT_DATA = 2,
  34. #define RLIMIT_DATA RLIMIT_DATA
  35. /* Maximum size of stack segment, in bytes. */
  36. RLIMIT_STACK = 3,
  37. #define RLIMIT_STACK RLIMIT_STACK
  38. /* Largest core file that can be created, in bytes. */
  39. RLIMIT_CORE = 4,
  40. #define RLIMIT_CORE RLIMIT_CORE
  41. /* Largest resident set size, in bytes.
  42. This affects swapping; processes that are exceeding their
  43. resident set size will be more likely to have physical memory
  44. taken from them. */
  45. __RLIMIT_RSS = 5,
  46. #define RLIMIT_RSS __RLIMIT_RSS
  47. /* Number of open files. */
  48. RLIMIT_NOFILE = 6,
  49. __RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
  50. #define RLIMIT_NOFILE RLIMIT_NOFILE
  51. #define RLIMIT_OFILE __RLIMIT_OFILE
  52. /* Address space limit (?) */
  53. RLIMIT_AS = 9,
  54. #define RLIMIT_AS RLIMIT_AS
  55. /* Number of processes. */
  56. __RLIMIT_NPROC = 7,
  57. #define RLIMIT_NPROC __RLIMIT_NPROC
  58. /* Locked-in-memory address space. */
  59. __RLIMIT_MEMLOCK = 8,
  60. #define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK
  61. /* Maximum number of file locks. */
  62. __RLIMIT_LOCKS = 10,
  63. #define RLIMIT_LOCKS __RLIMIT_LOCKS
  64. /* Maximum number of pending signals. */
  65. __RLIMIT_SIGPENDING = 11,
  66. #define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING
  67. /* Maximum bytes in POSIX message queues. */
  68. __RLIMIT_MSGQUEUE = 12,
  69. #define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE
  70. /* Maximum nice priority allowed to raise to.
  71. Nice levels 19 .. -20 correspond to 0 .. 39
  72. values of this resource limit. */
  73. __RLIMIT_NICE = 13,
  74. #define RLIMIT_NICE __RLIMIT_NICE
  75. /* Maximum realtime priority allowed for non-priviledged
  76. processes. */
  77. __RLIMIT_RTPRIO = 14,
  78. #define RLIMIT_RTPRIO __RLIMIT_RTPRIO
  79. __RLIMIT_NLIMITS = 15,
  80. __RLIM_NLIMITS = __RLIMIT_NLIMITS
  81. #define RLIMIT_NLIMITS __RLIMIT_NLIMITS
  82. #define RLIM_NLIMITS __RLIM_NLIMITS
  83. };
  84. /* Value to indicate that there is no limit. */
  85. #ifndef __USE_FILE_OFFSET64
  86. # define RLIM_INFINITY ((long int)(~0UL >> 1))
  87. #else
  88. # define RLIM_INFINITY 0x7fffffffffffffffLL
  89. #endif
  90. #ifdef __USE_LARGEFILE64
  91. # define RLIM64_INFINITY 0x7fffffffffffffffLL
  92. #endif
  93. /* We can represent all limits. */
  94. #define RLIM_SAVED_MAX RLIM_INFINITY
  95. #define RLIM_SAVED_CUR RLIM_INFINITY
  96. /* Type for resource quantity measurement. */
  97. #ifndef __USE_FILE_OFFSET64
  98. typedef __rlim_t rlim_t;
  99. #else
  100. typedef __rlim64_t rlim_t;
  101. #endif
  102. #ifdef __USE_LARGEFILE64
  103. typedef __rlim64_t rlim64_t;
  104. #endif
  105. struct rlimit
  106. {
  107. /* The current (soft) limit. */
  108. rlim_t rlim_cur;
  109. /* The hard limit. */
  110. rlim_t rlim_max;
  111. };
  112. #ifdef __USE_LARGEFILE64
  113. struct rlimit64
  114. {
  115. /* The current (soft) limit. */
  116. rlim64_t rlim_cur;
  117. /* The hard limit. */
  118. rlim64_t rlim_max;
  119. };
  120. #endif
  121. /* Whose usage statistics do you want? */
  122. enum __rusage_who
  123. {
  124. /* The calling process. */
  125. RUSAGE_SELF = 0,
  126. #define RUSAGE_SELF RUSAGE_SELF
  127. /* All of its terminated child processes. */
  128. RUSAGE_CHILDREN = -1
  129. #define RUSAGE_CHILDREN RUSAGE_CHILDREN
  130. };
  131. #define __need_timeval
  132. #include <bits/time.h> /* For `struct timeval'. */
  133. /* Structure which says how much of each resource has been used. */
  134. struct rusage
  135. {
  136. /* Total amount of user time used. */
  137. struct timeval ru_utime;
  138. /* Total amount of system time used. */
  139. struct timeval ru_stime;
  140. /* Maximum resident set size (in kilobytes). */
  141. long int ru_maxrss;
  142. /* Amount of sharing of text segment memory
  143. with other processes (kilobyte-seconds). */
  144. long int ru_ixrss;
  145. /* Amount of data segment memory used (kilobyte-seconds). */
  146. long int ru_idrss;
  147. /* Amount of stack memory used (kilobyte-seconds). */
  148. long int ru_isrss;
  149. /* Number of soft page faults (i.e. those serviced by reclaiming
  150. a page from the list of pages awaiting reallocation. */
  151. long int ru_minflt;
  152. /* Number of hard page faults (i.e. those that required I/O). */
  153. long int ru_majflt;
  154. /* Number of times a process was swapped out of physical memory. */
  155. long int ru_nswap;
  156. /* Number of input operations via the file system. Note: This
  157. and `ru_oublock' do not include operations with the cache. */
  158. long int ru_inblock;
  159. /* Number of output operations via the file system. */
  160. long int ru_oublock;
  161. /* Number of IPC messages sent. */
  162. long int ru_msgsnd;
  163. /* Number of IPC messages received. */
  164. long int ru_msgrcv;
  165. /* Number of signals delivered. */
  166. long int ru_nsignals;
  167. /* Number of voluntary context switches, i.e. because the process
  168. gave up the process before it had to (usually to wait for some
  169. resource to be available). */
  170. long int ru_nvcsw;
  171. /* Number of involuntary context switches, i.e. a higher priority process
  172. became runnable or the current process used up its time slice. */
  173. long int ru_nivcsw;
  174. };
  175. /* Priority limits. */
  176. #define PRIO_MIN -20 /* Minimum priority a process can have. */
  177. #define PRIO_MAX 20 /* Maximum priority a process can have. */
  178. /* The type of the WHICH argument to `getpriority' and `setpriority',
  179. indicating what flavor of entity the WHO argument specifies. */
  180. enum __priority_which
  181. {
  182. PRIO_PROCESS = 0, /* WHO is a process ID. */
  183. #define PRIO_PROCESS PRIO_PROCESS
  184. PRIO_PGRP = 1, /* WHO is a process group ID. */
  185. #define PRIO_PGRP PRIO_PGRP
  186. PRIO_USER = 2 /* WHO is a user ID. */
  187. #define PRIO_USER PRIO_USER
  188. };