resource.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* Bit values & structures for resource limits. 4.4 BSD/generic GNU version.
  2. Copyright (C) 1994-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  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. /* These are the values for 4.4 BSD and GNU. Earlier BSD systems have a
  20. subset of these kinds of resource limit. In systems where `getrlimit'
  21. and `setrlimit' are not system calls, these are the values used by the C
  22. library to emulate them. */
  23. /* Kinds of resource limit. */
  24. enum __rlimit_resource
  25. {
  26. /* Per-process CPU limit, in seconds. */
  27. RLIMIT_CPU,
  28. #define RLIMIT_CPU RLIMIT_CPU
  29. /* Largest file that can be created, in bytes. */
  30. RLIMIT_FSIZE,
  31. #define RLIMIT_FSIZE RLIMIT_FSIZE
  32. /* Maximum size of data segment, in bytes. */
  33. RLIMIT_DATA,
  34. #define RLIMIT_DATA RLIMIT_DATA
  35. /* Maximum size of stack segment, in bytes. */
  36. RLIMIT_STACK,
  37. #define RLIMIT_STACK RLIMIT_STACK
  38. /* Largest core file that can be created, in bytes. */
  39. RLIMIT_CORE,
  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,
  46. #define RLIMIT_RSS RLIMIT_RSS
  47. /* Locked-in-memory address space. */
  48. RLIMIT_MEMLOCK,
  49. #define RLIMIT_MEMLOCK RLIMIT_MEMLOCK
  50. /* Number of processes. */
  51. RLIMIT_NPROC,
  52. #define RLIMIT_NPROC RLIMIT_NPROC
  53. /* Number of open files. */
  54. RLIMIT_OFILE,
  55. RLIMIT_NOFILE = RLIMIT_OFILE, /* Another name for the same thing. */
  56. #define RLIMIT_OFILE RLIMIT_OFILE
  57. #define RLIMIT_NOFILE RLIMIT_NOFILE
  58. /* Maximum size of all socket buffers. */
  59. RLIMIT_SBSIZE,
  60. #define RLIMIT_SBSIZE RLIMIT_SBSIZE
  61. /* Maximum size in bytes of the process address space. */
  62. RLIMIT_AS,
  63. RLIMIT_VMEM = RLIMIT_AS, /* Another name for the same thing. */
  64. #define RLIMIT_AS RLIMIT_AS
  65. #define RLIMIT_VMEM RLIMIT_AS
  66. RLIMIT_NLIMITS, /* Number of limit flavors. */
  67. RLIM_NLIMITS = RLIMIT_NLIMITS /* Traditional name for same. */
  68. };
  69. /* Value to indicate that there is no limit. */
  70. #ifndef __USE_FILE_OFFSET64
  71. # define RLIM_INFINITY 0x7fffffff
  72. #else
  73. # define RLIM_INFINITY 0x7fffffffffffffffLL
  74. #endif
  75. #ifdef __USE_LARGEFILE64
  76. # define RLIM64_INFINITY 0x7fffffffffffffffLL
  77. #endif
  78. /* We can represent all limits. */
  79. #define RLIM_SAVED_MAX RLIM_INFINITY
  80. #define RLIM_SAVED_CUR RLIM_INFINITY
  81. /* Type for resource quantity measurement. */
  82. #ifndef __USE_FILE_OFFSET64
  83. typedef __rlim_t rlim_t;
  84. #else
  85. typedef __rlim64_t rlim_t;
  86. #endif
  87. #ifdef __USE_LARGEFILE64
  88. typedef __rlim64_t rlim64_t;
  89. #endif
  90. struct rlimit
  91. {
  92. /* The current (soft) limit. */
  93. rlim_t rlim_cur;
  94. /* The hard limit. */
  95. rlim_t rlim_max;
  96. };
  97. #ifdef __USE_LARGEFILE64
  98. struct rlimit64
  99. {
  100. /* The current (soft) limit. */
  101. rlim64_t rlim_cur;
  102. /* The hard limit. */
  103. rlim64_t rlim_max;
  104. };
  105. #endif
  106. /* Whose usage statistics do you want? */
  107. enum __rusage_who
  108. /* The macro definitions are necessary because some programs want
  109. to test for operating system features with #ifdef RUSAGE_SELF.
  110. In ISO C the reflexive definition is a no-op. */
  111. {
  112. /* The calling process. */
  113. RUSAGE_SELF = 0,
  114. #define RUSAGE_SELF RUSAGE_SELF
  115. /* All of its terminated child processes. */
  116. RUSAGE_CHILDREN = -1
  117. #define RUSAGE_CHILDREN RUSAGE_CHILDREN
  118. };
  119. #include <bits/types/struct_timeval.h>
  120. #include <bits/types/struct_rusage.h>
  121. /* Priority limits. */
  122. #define PRIO_MIN -20 /* Minimum priority a process can have. */
  123. #define PRIO_MAX 20 /* Maximum priority a process can have. */
  124. /* The type of the WHICH argument to `getpriority' and `setpriority',
  125. indicating what flavor of entity the WHO argument specifies. */
  126. enum __priority_which
  127. {
  128. PRIO_PROCESS = 0, /* WHO is a process ID. */
  129. #define PRIO_PROCESS PRIO_PROCESS
  130. PRIO_PGRP = 1, /* WHO is a process group ID. */
  131. #define PRIO_PGRP PRIO_PGRP
  132. PRIO_USER = 2 /* WHO is a user ID. */
  133. #define PRIO_USER PRIO_USER
  134. };