steep 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/exe/rbs +1 -1
  4. data/lib/steep/annotation_parser.rb +4 -4
  5. data/lib/steep/ast/buffer.rb +11 -7
  6. data/lib/steep/ast/builtin.rb +8 -0
  7. data/lib/steep/ast/types/factory.rb +55 -55
  8. data/lib/steep/drivers/check.rb +20 -4
  9. data/lib/steep/drivers/langserver.rb +6 -1
  10. data/lib/steep/drivers/vendor.rb +2 -2
  11. data/lib/steep/project/completion_provider.rb +5 -11
  12. data/lib/steep/project/dsl.rb +14 -0
  13. data/lib/steep/project/file.rb +42 -46
  14. data/lib/steep/project/hover_content.rb +11 -5
  15. data/lib/steep/project/options.rb +25 -3
  16. data/lib/steep/project/target.rb +10 -4
  17. data/lib/steep/signature/errors.rb +1 -1
  18. data/lib/steep/signature/validator.rb +8 -8
  19. data/lib/steep/source.rb +1 -1
  20. data/lib/steep/type_construction.rb +987 -711
  21. data/lib/steep/type_inference/constant_env.rb +1 -1
  22. data/lib/steep/type_inference/context.rb +7 -3
  23. data/lib/steep/type_inference/context_array.rb +111 -0
  24. data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
  25. data/lib/steep/type_inference/logic.rb +130 -0
  26. data/lib/steep/type_inference/type_env.rb +5 -69
  27. data/lib/steep/typing.rb +79 -22
  28. data/lib/steep/version.rb +1 -1
  29. data/lib/steep.rb +6 -1
  30. data/smoke/alias/Steepfile +1 -0
  31. data/smoke/and/Steepfile +1 -0
  32. data/smoke/array/Steepfile +1 -0
  33. data/smoke/array/b.rb +0 -2
  34. data/smoke/block/Steepfile +1 -0
  35. data/smoke/case/Steepfile +1 -0
  36. data/smoke/class/Steepfile +1 -0
  37. data/smoke/const/Steepfile +1 -0
  38. data/smoke/dstr/Steepfile +1 -0
  39. data/smoke/ensure/Steepfile +1 -0
  40. data/smoke/enumerator/Steepfile +1 -0
  41. data/smoke/extension/Steepfile +1 -0
  42. data/smoke/extension/c.rb +1 -0
  43. data/smoke/hash/Steepfile +1 -0
  44. data/smoke/hello/Steepfile +1 -0
  45. data/smoke/if/Steepfile +1 -0
  46. data/smoke/if/a.rb +1 -1
  47. data/smoke/implements/Steepfile +1 -0
  48. data/smoke/initialize/Steepfile +1 -0
  49. data/smoke/integer/Steepfile +1 -0
  50. data/smoke/interface/Steepfile +1 -0
  51. data/smoke/kwbegin/Steepfile +1 -0
  52. data/smoke/lambda/Steepfile +1 -0
  53. data/smoke/literal/Steepfile +1 -0
  54. data/smoke/map/Steepfile +1 -0
  55. data/smoke/method/Steepfile +1 -0
  56. data/smoke/module/Steepfile +1 -0
  57. data/smoke/regexp/Steepfile +1 -0
  58. data/smoke/regression/Steepfile +1 -0
  59. data/smoke/rescue/Steepfile +1 -0
  60. data/smoke/rescue/a.rb +1 -1
  61. data/smoke/self/Steepfile +1 -0
  62. data/smoke/skip/Steepfile +1 -0
  63. data/smoke/stdout/Steepfile +1 -0
  64. data/smoke/super/Steepfile +1 -0
  65. data/smoke/type_case/Steepfile +1 -0
  66. data/smoke/yield/Steepfile +1 -0
  67. data/steep.gemspec +1 -1
  68. data/vendor/ruby-signature/.gitignore +2 -2
  69. data/vendor/ruby-signature/README.md +2 -2
  70. data/vendor/ruby-signature/Rakefile +2 -2
  71. data/vendor/ruby-signature/bin/annotate-with-rdoc +14 -13
  72. data/vendor/ruby-signature/bin/console +1 -1
  73. data/vendor/ruby-signature/bin/sort +7 -6
  74. data/vendor/ruby-signature/bin/test_runner.rb +0 -1
  75. data/vendor/ruby-signature/docs/CONTRIBUTING.md +1 -1
  76. data/vendor/ruby-signature/docs/sigs.md +3 -3
  77. data/vendor/ruby-signature/docs/stdlib.md +1 -1
  78. data/vendor/ruby-signature/docs/syntax.md +9 -9
  79. data/vendor/ruby-signature/exe/rbs +5 -1
  80. data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +27 -0
  81. data/vendor/ruby-signature/lib/rbs/ast/comment.rb +27 -0
  82. data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +395 -0
  83. data/vendor/ruby-signature/lib/rbs/ast/members.rb +362 -0
  84. data/vendor/ruby-signature/lib/rbs/buffer.rb +50 -0
  85. data/vendor/ruby-signature/lib/rbs/builtin_names.rb +55 -0
  86. data/vendor/ruby-signature/lib/rbs/cli.rb +558 -0
  87. data/vendor/ruby-signature/lib/rbs/constant.rb +26 -0
  88. data/vendor/ruby-signature/lib/rbs/constant_table.rb +150 -0
  89. data/vendor/ruby-signature/lib/rbs/definition.rb +170 -0
  90. data/vendor/ruby-signature/lib/rbs/definition_builder.rb +919 -0
  91. data/vendor/ruby-signature/lib/rbs/environment.rb +281 -0
  92. data/vendor/ruby-signature/lib/rbs/environment_loader.rb +136 -0
  93. data/vendor/ruby-signature/lib/rbs/environment_walker.rb +124 -0
  94. data/vendor/ruby-signature/lib/rbs/errors.rb +187 -0
  95. data/vendor/ruby-signature/lib/rbs/location.rb +102 -0
  96. data/vendor/ruby-signature/lib/rbs/method_type.rb +123 -0
  97. data/vendor/ruby-signature/lib/rbs/namespace.rb +91 -0
  98. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.rb +21 -23
  99. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.y +18 -18
  100. data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +553 -0
  101. data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +587 -0
  102. data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +381 -0
  103. data/vendor/ruby-signature/lib/rbs/substitution.rb +46 -0
  104. data/vendor/ruby-signature/lib/rbs/test/errors.rb +61 -0
  105. data/vendor/ruby-signature/lib/rbs/test/hook.rb +294 -0
  106. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/test/setup.rb +7 -7
  107. data/vendor/ruby-signature/lib/rbs/test/spy.rb +325 -0
  108. data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +183 -0
  109. data/vendor/ruby-signature/lib/rbs/test/type_check.rb +254 -0
  110. data/vendor/ruby-signature/lib/rbs/test.rb +26 -0
  111. data/vendor/ruby-signature/lib/rbs/type_name.rb +70 -0
  112. data/vendor/ruby-signature/lib/rbs/types.rb +936 -0
  113. data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +138 -0
  114. data/vendor/ruby-signature/lib/rbs/vendorer.rb +47 -0
  115. data/vendor/ruby-signature/lib/rbs/version.rb +3 -0
  116. data/vendor/ruby-signature/lib/rbs/writer.rb +269 -0
  117. data/vendor/ruby-signature/lib/rbs.rb +64 -0
  118. data/vendor/ruby-signature/lib/ruby/signature.rb +4 -61
  119. data/vendor/ruby-signature/{ruby-signature.gemspec → rbs.gemspec} +4 -4
  120. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +58 -1
  121. data/vendor/ruby-signature/stdlib/base64/base64.rbs +69 -13
  122. data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +372 -0
  123. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +9 -0
  124. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +1 -7
  125. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +2 -1
  126. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +3 -2
  127. data/vendor/ruby-signature/stdlib/builtin/file.rbs +902 -302
  128. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +190 -68
  129. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +3 -6
  130. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +6 -4
  131. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +146 -120
  132. data/vendor/ruby-signature/stdlib/builtin/math.rbs +310 -7
  133. data/vendor/ruby-signature/stdlib/builtin/method.rbs +11 -8
  134. data/vendor/ruby-signature/stdlib/builtin/module.rbs +959 -103
  135. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +3 -0
  136. data/vendor/ruby-signature/stdlib/builtin/process.rbs +981 -108
  137. data/vendor/ruby-signature/stdlib/builtin/random.rbs +215 -41
  138. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +47 -0
  139. data/vendor/ruby-signature/stdlib/builtin/string.rbs +9 -2
  140. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +282 -11
  141. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +11 -13
  142. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +25 -29
  143. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +1 -1
  144. data/vendor/ruby-signature/stdlib/builtin/time.rbs +875 -567
  145. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +243 -44
  146. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +103 -109
  147. data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +62 -0
  148. data/vendor/ruby-signature/stdlib/csv/csv.rbs +773 -0
  149. data/vendor/ruby-signature/stdlib/erb/erb.rbs +375 -1
  150. data/vendor/ruby-signature/stdlib/find/find.rbs +0 -4
  151. data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +247 -0
  152. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +1088 -16
  153. data/vendor/ruby-signature/stdlib/set/set.rbs +251 -27
  154. metadata +49 -44
  155. data/exe/ruby-signature +0 -3
  156. data/vendor/ruby-signature/exe/ruby-signature +0 -7
  157. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
  158. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
  159. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
  160. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
  161. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
  162. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
  163. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -555
  164. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
  165. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
  166. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
  167. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
  168. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
  169. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
  170. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
  171. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
  172. data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
  173. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
  174. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
  175. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -444
  176. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
  177. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
  178. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
  179. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
  180. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
  181. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -327
  182. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
  183. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
  184. data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
  185. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
  186. data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
  187. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
  188. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
  189. data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
  190. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
@@ -1,345 +1,1218 @@
1
- # [Module](https://ruby-doc.org/core-2.6.3/Module.html) to handle
2
- # processes.
1
+ # The module contains several groups of functionality for handling OS processes:
2
+ #
3
+ # * Low-level property introspection and management of the current process,
4
+ # like Process.argv0, Process.pid;
5
+ # * Low-level introspection of other processes, like Process.getpgid,
6
+ # Process.getpriority;
7
+ # * Management of the current process: Process.abort, Process.exit,
8
+ # Process.daemon, etc. (for convenience, most of those are also available as
9
+ # global functions and module functions of Kernel);
10
+ # * Creation and management of child processes: Process.fork, Process.spawn,
11
+ # and related methods;
12
+ # * Management of low-level system clock: Process.times and
13
+ # Process.clock_gettime, which could be important for proper benchmarking
14
+ # and other elapsed time measurement tasks.
15
+ #
16
+ #
3
17
  module Process
4
- # Returns the name of the script being executed. The value is not affected
5
- # by assigning a new value to $0.
6
- #
7
- # This method first appeared in Ruby 2.1 to serve as a global variable
8
- # free means to get the script name.
18
+ # Returns the name of the script being executed. The value is not affected by
19
+ # assigning a new value to $0.
20
+ #
21
+ # This method first appeared in Ruby 2.1 to serve as a global variable free
22
+ # means to get the script name.
23
+ #
9
24
  def self.argv0: () -> String
10
25
 
26
+ # Returns the time resolution returned by POSIX clock_getres() function.
27
+ #
28
+ # `clock_id` specifies a kind of clock. See the document of
29
+ # `Process.clock_gettime` for details.
30
+ #
31
+ # `clock_id` can be a symbol as `Process.clock_gettime`. However the result may
32
+ # not be accurate. For example,
33
+ # `Process.clock_getres(:GETTIMEOFDAY_BASED_CLOCK_REALTIME)` returns 1.0e-06
34
+ # which means 1 microsecond, but actual resolution can be more coarse.
35
+ #
36
+ # If the given `clock_id` is not supported, Errno::EINVAL is raised.
37
+ #
38
+ # `unit` specifies a type of the return value. `Process.clock_getres` accepts
39
+ # `unit` as `Process.clock_gettime`. The default value, `:float_second`, is also
40
+ # same as `Process.clock_gettime`.
41
+ #
42
+ # `Process.clock_getres` also accepts `:hertz` as `unit`. `:hertz` means a the
43
+ # reciprocal of `:float_second`.
44
+ #
45
+ # `:hertz` can be used to obtain the exact value of the clock ticks per second
46
+ # for times() function and CLOCKS_PER_SEC for clock() function.
47
+ #
48
+ # `Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)` returns
49
+ # the clock ticks per second.
50
+ #
51
+ # `Process.clock_getres(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)` returns
52
+ # CLOCKS_PER_SEC.
53
+ #
54
+ # p Process.clock_getres(Process::CLOCK_MONOTONIC)
55
+ # #=> 1.0e-09
56
+ #
11
57
  def self.clock_getres: (Symbol | Integer clock_id, ?Symbol unit) -> (Float | Integer)
12
58
 
59
+ # Returns a time returned by POSIX clock_gettime() function.
60
+ #
61
+ # p Process.clock_gettime(Process::CLOCK_MONOTONIC)
62
+ # #=> 896053.968060096
63
+ #
64
+ # `clock_id` specifies a kind of clock. It is specified as a constant which
65
+ # begins with `Process::CLOCK_` such as Process::CLOCK_REALTIME and
66
+ # Process::CLOCK_MONOTONIC.
67
+ #
68
+ # The supported constants depends on OS and version. Ruby provides following
69
+ # types of `clock_id` if available.
70
+ #
71
+ # CLOCK_REALTIME
72
+ # : SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS
73
+ # 10.12
74
+ # CLOCK_MONOTONIC
75
+ # : SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS
76
+ # 10.12
77
+ # CLOCK_PROCESS_CPUTIME_ID
78
+ # : SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3, OpenBSD 5.4, macOS 10.12
79
+ # CLOCK_THREAD_CPUTIME_ID
80
+ # : SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12
81
+ # CLOCK_VIRTUAL
82
+ # : FreeBSD 3.0, OpenBSD 2.1
83
+ # CLOCK_PROF
84
+ # : FreeBSD 3.0, OpenBSD 2.1
85
+ # CLOCK_REALTIME_FAST
86
+ # : FreeBSD 8.1
87
+ # CLOCK_REALTIME_PRECISE
88
+ # : FreeBSD 8.1
89
+ # CLOCK_REALTIME_COARSE
90
+ # : Linux 2.6.32
91
+ # CLOCK_REALTIME_ALARM
92
+ # : Linux 3.0
93
+ # CLOCK_MONOTONIC_FAST
94
+ # : FreeBSD 8.1
95
+ # CLOCK_MONOTONIC_PRECISE
96
+ # : FreeBSD 8.1
97
+ # CLOCK_MONOTONIC_COARSE
98
+ # : Linux 2.6.32
99
+ # CLOCK_MONOTONIC_RAW
100
+ # : Linux 2.6.28, macOS 10.12
101
+ # CLOCK_MONOTONIC_RAW_APPROX
102
+ # : macOS 10.12
103
+ # CLOCK_BOOTTIME
104
+ # : Linux 2.6.39
105
+ # CLOCK_BOOTTIME_ALARM
106
+ # : Linux 3.0
107
+ # CLOCK_UPTIME
108
+ # : FreeBSD 7.0, OpenBSD 5.5
109
+ # CLOCK_UPTIME_FAST
110
+ # : FreeBSD 8.1
111
+ # CLOCK_UPTIME_RAW
112
+ # : macOS 10.12
113
+ # CLOCK_UPTIME_RAW_APPROX
114
+ # : macOS 10.12
115
+ # CLOCK_UPTIME_PRECISE
116
+ # : FreeBSD 8.1
117
+ # CLOCK_SECOND
118
+ # : FreeBSD 8.1
119
+ # CLOCK_TAI
120
+ # : Linux 3.10
121
+ #
122
+ #
123
+ # Note that SUS stands for Single Unix Specification. SUS contains POSIX and
124
+ # clock_gettime is defined in the POSIX part. SUS defines CLOCK_REALTIME
125
+ # mandatory but CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID and
126
+ # CLOCK_THREAD_CPUTIME_ID are optional.
127
+ #
128
+ # Also, several symbols are accepted as `clock_id`. There are emulations for
129
+ # clock_gettime().
130
+ #
131
+ # For example, Process::CLOCK_REALTIME is defined as
132
+ # `:GETTIMEOFDAY_BASED_CLOCK_REALTIME` when clock_gettime() is not available.
133
+ #
134
+ # Emulations for `CLOCK_REALTIME`:
135
+ # :GETTIMEOFDAY_BASED_CLOCK_REALTIME
136
+ # : Use gettimeofday() defined by SUS. (SUSv4 obsoleted it, though.) The
137
+ # resolution is 1 microsecond.
138
+ # :TIME_BASED_CLOCK_REALTIME
139
+ # : Use time() defined by ISO C. The resolution is 1 second.
140
+ #
141
+ #
142
+ # Emulations for `CLOCK_MONOTONIC`:
143
+ # :MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC
144
+ # : Use mach_absolute_time(), available on Darwin. The resolution is CPU
145
+ # dependent.
146
+ # :TIMES_BASED_CLOCK_MONOTONIC
147
+ # : Use the result value of times() defined by POSIX. POSIX defines it as
148
+ # "times() shall return the elapsed real time, in clock ticks, since an
149
+ # arbitrary point in the past (for example, system start-up time)". For
150
+ # example, GNU/Linux returns a value based on jiffies and it is monotonic.
151
+ # However, 4.4BSD uses gettimeofday() and it is not monotonic. (FreeBSD uses
152
+ # clock_gettime(CLOCK_MONOTONIC) instead, though.) The resolution is the
153
+ # clock tick. "getconf CLK_TCK" command shows the clock ticks per second.
154
+ # (The clock ticks per second is defined by HZ macro in older systems.) If
155
+ # it is 100 and clock_t is 32 bits integer type, the resolution is 10
156
+ # millisecond and cannot represent over 497 days.
157
+ #
158
+ #
159
+ # Emulations for `CLOCK_PROCESS_CPUTIME_ID`:
160
+ # :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID
161
+ # : Use getrusage() defined by SUS. getrusage() is used with RUSAGE_SELF to
162
+ # obtain the time only for the calling process (excluding the time for child
163
+ # processes). The result is addition of user time (ru_utime) and system time
164
+ # (ru_stime). The resolution is 1 microsecond.
165
+ # :TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID
166
+ # : Use times() defined by POSIX. The result is addition of user time
167
+ # (tms_utime) and system time (tms_stime). tms_cutime and tms_cstime are
168
+ # ignored to exclude the time for child processes. The resolution is the
169
+ # clock tick. "getconf CLK_TCK" command shows the clock ticks per second.
170
+ # (The clock ticks per second is defined by HZ macro in older systems.) If
171
+ # it is 100, the resolution is 10 millisecond.
172
+ # :CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID
173
+ # : Use clock() defined by ISO C. The resolution is 1/CLOCKS_PER_SEC.
174
+ # CLOCKS_PER_SEC is the C-level macro defined by time.h. SUS defines
175
+ # CLOCKS_PER_SEC is 1000000. Non-Unix systems may define it a different
176
+ # value, though. If CLOCKS_PER_SEC is 1000000 as SUS, the resolution is 1
177
+ # microsecond. If CLOCKS_PER_SEC is 1000000 and clock_t is 32 bits integer
178
+ # type, it cannot represent over 72 minutes.
179
+ #
180
+ #
181
+ # If the given `clock_id` is not supported, Errno::EINVAL is raised.
182
+ #
183
+ # `unit` specifies a type of the return value.
184
+ #
185
+ # :float_second
186
+ # : number of seconds as a float (default)
187
+ # :float_millisecond
188
+ # : number of milliseconds as a float
189
+ # :float_microsecond
190
+ # : number of microseconds as a float
191
+ # :second
192
+ # : number of seconds as an integer
193
+ # :millisecond
194
+ # : number of milliseconds as an integer
195
+ # :microsecond
196
+ # : number of microseconds as an integer
197
+ # :nanosecond
198
+ # : number of nanoseconds as an integer
199
+ #
200
+ #
201
+ # The underlying function, clock_gettime(), returns a number of nanoseconds.
202
+ # Float object (IEEE 754 double) is not enough to represent the return value for
203
+ # CLOCK_REALTIME. If the exact nanoseconds value is required, use `:nanoseconds`
204
+ # as the `unit`.
205
+ #
206
+ # The origin (zero) of the returned value varies. For example, system start up
207
+ # time, process start up time, the Epoch, etc.
208
+ #
209
+ # The origin in CLOCK_REALTIME is defined as the Epoch (1970-01-01 00:00:00
210
+ # UTC). But some systems count leap seconds and others doesn't. So the result
211
+ # can be interpreted differently across systems. Time.now is recommended over
212
+ # CLOCK_REALTIME.
213
+ #
13
214
  def self.clock_gettime: (Symbol | Integer clock_id, ?Symbol unit) -> (Float | Integer)
14
215
 
216
+ # Detach the process from controlling terminal and run in the background as
217
+ # system daemon. Unless the argument nochdir is true (i.e. non false), it
218
+ # changes the current working directory to the root ("/"). Unless the argument
219
+ # noclose is true, daemon() will redirect standard input, standard output and
220
+ # standard error to /dev/null. Return zero on success, or raise one of Errno::*.
221
+ #
15
222
  def self.daemon: (?untyped nochdir, ?untyped noclose) -> Integer
16
223
 
224
+ # Some operating systems retain the status of terminated child processes until
225
+ # the parent collects that status (normally using some variant of `wait()`). If
226
+ # the parent never collects this status, the child stays around as a *zombie*
227
+ # process. Process::detach prevents this by setting up a separate Ruby thread
228
+ # whose sole job is to reap the status of the process *pid* when it terminates.
229
+ # Use #detach only when you do not intend to explicitly wait for the child to
230
+ # terminate.
231
+ #
232
+ # The waiting thread returns the exit status of the detached process when it
233
+ # terminates, so you can use Thread#join to know the result. If specified *pid*
234
+ # is not a valid child process ID, the thread returns `nil` immediately.
235
+ #
236
+ # The waiting thread has #pid method which returns the pid.
237
+ #
238
+ # In this first example, we don't reap the first child process, so it appears as
239
+ # a zombie in the process status display.
240
+ #
241
+ # p1 = fork { sleep 0.1 }
242
+ # p2 = fork { sleep 0.2 }
243
+ # Process.waitpid(p2)
244
+ # sleep 2
245
+ # system("ps -ho pid,state -p #{p1}")
246
+ #
247
+ # *produces:*
248
+ #
249
+ # 27389 Z
250
+ #
251
+ # In the next example, Process::detach is used to reap the child automatically.
252
+ #
253
+ # p1 = fork { sleep 0.1 }
254
+ # p2 = fork { sleep 0.2 }
255
+ # Process.detach(p1)
256
+ # Process.waitpid(p2)
257
+ # sleep 2
258
+ # system("ps -ho pid,state -p #{p1}")
259
+ #
260
+ # *(produces no output)*
261
+ #
17
262
  def self.detach: (Integer pid) -> Thread
18
263
 
19
264
  # Returns the effective group ID for this process. Not available on all
20
265
  # platforms.
21
- #
22
- # ```ruby
23
- # Process.egid #=> 500
24
- # ```
266
+ #
267
+ # Process.egid #=> 500
268
+ #
25
269
  def self.egid: () -> Integer
26
270
 
271
+ # Sets the effective group ID for this process. Not available on all platforms.
272
+ #
27
273
  def self.egid=: (Integer arg0) -> Integer
28
274
 
29
275
  # Returns the effective user ID for this process.
30
- #
31
- # ```ruby
32
- # Process.euid #=> 501
33
- # ```
276
+ #
277
+ # Process.euid #=> 501
278
+ #
34
279
  def self.euid: () -> Integer
35
280
 
281
+ # Sets the effective user ID for this process. Not available on all platforms.
282
+ #
36
283
  def self.euid=: (Integer arg0) -> Integer
37
284
 
285
+ # Returns the process group ID for the given process id. Not available on all
286
+ # platforms.
287
+ #
288
+ # Process.getpgid(Process.ppid()) #=> 25527
289
+ #
38
290
  def self.getpgid: (Integer pid) -> Integer
39
291
 
40
- # Returns the process group ID for this process. Not available on all
41
- # platforms.
42
- #
43
- # ```ruby
44
- # Process.getpgid(0) #=> 25527
45
- # Process.getpgrp #=> 25527
46
- # ```
292
+ # Returns the process group ID for this process. Not available on all platforms.
293
+ #
294
+ # Process.getpgid(0) #=> 25527
295
+ # Process.getpgrp #=> 25527
296
+ #
47
297
  def self.getpgrp: () -> Integer
48
298
 
299
+ # Gets the scheduling priority for specified process, process group, or user.
300
+ # *kind* indicates the kind of entity to find: one of Process::PRIO_PGRP,
301
+ # Process::PRIO_USER, or Process::PRIO_PROCESS. *integer* is an id indicating
302
+ # the particular process, process group, or user (an id of 0 means *current*).
303
+ # Lower priorities are more favorable for scheduling. Not available on all
304
+ # platforms.
305
+ #
306
+ # Process.getpriority(Process::PRIO_USER, 0) #=> 19
307
+ # Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19
308
+ #
49
309
  def self.getpriority: (Integer kind, Integer arg0) -> Integer
50
310
 
311
+ # Gets the resource limit of the process. *cur_limit* means current (soft) limit
312
+ # and *max_limit* means maximum (hard) limit.
313
+ #
314
+ # *resource* indicates the kind of resource to limit. It is specified as a
315
+ # symbol such as `:CORE`, a string such as `"CORE"` or a constant such as
316
+ # Process::RLIMIT_CORE. See Process.setrlimit for details.
317
+ #
318
+ # *cur_limit* and *max_limit* may be Process::RLIM_INFINITY,
319
+ # Process::RLIM_SAVED_MAX or Process::RLIM_SAVED_CUR. See Process.setrlimit and
320
+ # the system getrlimit(2) manual for details.
321
+ #
51
322
  def self.getrlimit: (Symbol | String | Integer resource) -> [ Integer, Integer ]
52
323
 
324
+ # Returns the session ID for the given process id. If not given, return current
325
+ # process sid. Not available on all platforms.
326
+ #
327
+ # Process.getsid() #=> 27422
328
+ # Process.getsid(0) #=> 27422
329
+ # Process.getsid(Process.pid()) #=> 27422
330
+ #
53
331
  def self.getsid: (?Integer pid) -> Integer
54
332
 
55
333
  # Returns the (real) group ID for this process.
56
- #
57
- # ```ruby
58
- # Process.gid #=> 500
59
- # ```
334
+ #
335
+ # Process.gid #=> 500
336
+ #
60
337
  def self.gid: () -> Integer
61
338
 
339
+ # Sets the group ID for this process.
340
+ #
62
341
  def self.gid=: (Integer arg0) -> Integer
63
342
 
64
- # Get an `Array` of the group IDs in the supplemental group access list
65
- # for this process.
66
- #
67
- # ```ruby
68
- # Process.groups #=> [27, 6, 10, 11]
69
- # ```
70
- #
71
- # Note that this method is just a wrapper of getgroups(2). This means that
72
- # the following characteristics of the result completely depend on your
73
- # system:
74
- #
75
- # - the result is sorted
76
- #
77
- # - the result includes effective GIDs
78
- #
79
- # - the result does not include duplicated GIDs
80
- #
81
- # You can make sure to get a sorted unique
82
- # [GID](https://ruby-doc.org/core-2.6.3/Process/GID.html) list of the
83
- # current process by this expression:
84
- #
85
- # ```ruby
86
- # Process.groups.uniq.sort
87
- # ```
343
+ # Get an Array of the group IDs in the supplemental group access list for this
344
+ # process.
345
+ #
346
+ # Process.groups #=> [27, 6, 10, 11]
347
+ #
348
+ # Note that this method is just a wrapper of getgroups(2). This means that the
349
+ # following characteristics of the result completely depend on your system:
350
+ #
351
+ # * the result is sorted
352
+ # * the result includes effective GIDs
353
+ # * the result does not include duplicated GIDs
354
+ #
355
+ #
356
+ # You can make sure to get a sorted unique GID list of the current process by
357
+ # this expression:
358
+ #
359
+ # Process.groups.uniq.sort
360
+ #
88
361
  def self.groups: () -> ::Array[Integer]
89
362
 
363
+ # Set the supplemental group access list to the given Array of group IDs.
364
+ #
365
+ # Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
366
+ # Process.groups = [27, 6, 10, 11] #=> [27, 6, 10, 11]
367
+ # Process.groups #=> [27, 6, 10, 11]
368
+ #
90
369
  def self.groups=: (::Array[Integer] arg0) -> ::Array[Integer]
91
370
 
371
+ # Initializes the supplemental group access list by reading the system group
372
+ # database and using all groups of which the given user is a member. The group
373
+ # with the specified *gid* is also added to the list. Returns the resulting
374
+ # Array of the gids of all the groups in the supplementary group access list.
375
+ # Not available on all platforms.
376
+ #
377
+ # Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
378
+ # Process.initgroups( "mgranger", 30 ) #=> [30, 6, 10, 11]
379
+ # Process.groups #=> [30, 6, 10, 11]
380
+ #
92
381
  def self.initgroups: (String username, Integer gid) -> ::Array[Integer]
93
382
 
383
+ # Sends the given signal to the specified process id(s) if *pid* is positive. If
384
+ # *pid* is zero, *signal* is sent to all processes whose group ID is equal to
385
+ # the group ID of the process. If *pid* is negative, results are dependent on
386
+ # the operating system. *signal* may be an integer signal number or a POSIX
387
+ # signal name (either with or without a `SIG` prefix). If *signal* is negative
388
+ # (or starts with a minus sign), kills process groups instead of processes. Not
389
+ # all signals are available on all platforms. The keys and values of Signal.list
390
+ # are known signal names and numbers, respectively.
391
+ #
392
+ # pid = fork do
393
+ # Signal.trap("HUP") { puts "Ouch!"; exit }
394
+ # # ... do some work ...
395
+ # end
396
+ # # ...
397
+ # Process.kill("HUP", pid)
398
+ # Process.wait
399
+ #
400
+ # *produces:*
401
+ #
402
+ # Ouch!
403
+ #
404
+ # If *signal* is an integer but wrong for signal, Errno::EINVAL or RangeError
405
+ # will be raised. Otherwise unless *signal* is a String or a Symbol, and a
406
+ # known signal name, ArgumentError will be raised.
407
+ #
408
+ # Also, Errno::ESRCH or RangeError for invalid *pid*, Errno::EPERM when failed
409
+ # because of no privilege, will be raised. In these cases, signals may have
410
+ # been sent to preceding processes.
411
+ #
94
412
  def self.kill: (Integer | Symbol | String signal, *Integer pids) -> Integer
95
413
 
96
- # Returns the maximum number of gids allowed in the supplemental group
97
- # access list.
98
- #
99
- # ```ruby
100
- # Process.maxgroups #=> 32
101
- # ```
414
+ # Returns the maximum number of gids allowed in the supplemental group access
415
+ # list.
416
+ #
417
+ # Process.maxgroups #=> 32
418
+ #
102
419
  def self.maxgroups: () -> Integer
103
420
 
421
+ # Sets the maximum number of gids allowed in the supplemental group access list.
422
+ #
104
423
  def self.maxgroups=: (Integer arg0) -> Integer
105
424
 
106
425
  # Returns the process id of this process. Not available on all platforms.
107
- #
108
- # ```ruby
109
- # Process.pid #=> 27415
110
- # ```
426
+ #
427
+ # Process.pid #=> 27415
428
+ #
111
429
  def self.pid: () -> Integer
112
430
 
113
- # Returns the process id of the parent of this process. Returns
114
- # untrustworthy value on Win32/64. Not available on all platforms.
115
- #
116
- # ```ruby
117
- # puts "I am #{Process.pid}"
118
- # Process.fork { puts "Dad is #{Process.ppid}" }
119
- # ```
120
- #
431
+ # Returns the process id of the parent of this process. Returns untrustworthy
432
+ # value on Win32/64. Not available on all platforms.
433
+ #
434
+ # puts "I am #{Process.pid}"
435
+ # Process.fork { puts "Dad is #{Process.ppid}" }
436
+ #
121
437
  # *produces:*
122
- #
123
- # ```ruby
124
- # I am 27417
125
- # Dad is 27417
126
- # ```
438
+ #
439
+ # I am 27417
440
+ # Dad is 27417
441
+ #
127
442
  def self.ppid: () -> Integer
128
443
 
444
+ # Sets the process group ID of *pid* (0 indicates this process) to *integer*.
445
+ # Not available on all platforms.
446
+ #
129
447
  def self.setpgid: (Integer pid, Integer arg0) -> Integer
130
448
 
449
+ # See Process.getpriority.
450
+ #
451
+ # Process.setpriority(Process::PRIO_USER, 0, 19) #=> 0
452
+ # Process.setpriority(Process::PRIO_PROCESS, 0, 19) #=> 0
453
+ # Process.getpriority(Process::PRIO_USER, 0) #=> 19
454
+ # Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19
455
+ #
131
456
  def self.setpriority: (Integer kind, Integer arg0, Integer priority) -> Integer
132
457
 
458
+ # Sets the process title that appears on the ps(1) command. Not necessarily
459
+ # effective on all platforms. No exception will be raised regardless of the
460
+ # result, nor will NotImplementedError be raised even if the platform does not
461
+ # support the feature.
462
+ #
463
+ # Calling this method does not affect the value of $0.
464
+ #
465
+ # Process.setproctitle('myapp: worker #%d' % worker_id)
466
+ #
467
+ # This method first appeared in Ruby 2.1 to serve as a global variable free
468
+ # means to change the process title.
469
+ #
133
470
  def self.setproctitle: (String arg0) -> String
134
471
 
135
- def self.setrlimit: (Symbol | String | Integer resource, Integer cur_limit, ?Integer max_limit) -> NilClass
136
-
137
- # Establishes this process as a new session and process group leader, with
138
- # no controlling tty. Returns the session id. Not available on all
139
- # platforms.
140
- #
141
- # ```ruby
142
- # Process.setsid #=> 27422
143
- # ```
472
+ # Sets the resource limit of the process. *cur_limit* means current (soft) limit
473
+ # and *max_limit* means maximum (hard) limit.
474
+ #
475
+ # If *max_limit* is not given, *cur_limit* is used.
476
+ #
477
+ # *resource* indicates the kind of resource to limit. It should be a symbol such
478
+ # as `:CORE`, a string such as `"CORE"` or a constant such as
479
+ # Process::RLIMIT_CORE. The available resources are OS dependent. Ruby may
480
+ # support following resources.
481
+ #
482
+ # AS
483
+ # : total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but
484
+ # 4.4BSD-Lite)
485
+ # CORE
486
+ # : core size (bytes) (SUSv3)
487
+ # CPU
488
+ # : CPU time (seconds) (SUSv3)
489
+ # DATA
490
+ # : data segment (bytes) (SUSv3)
491
+ # FSIZE
492
+ # : file size (bytes) (SUSv3)
493
+ # MEMLOCK
494
+ # : total size for mlock(2) (bytes) (4.4BSD, GNU/Linux)
495
+ # MSGQUEUE
496
+ # : allocation for POSIX message queues (bytes) (GNU/Linux)
497
+ # NICE
498
+ # : ceiling on process's nice(2) value (number) (GNU/Linux)
499
+ # NOFILE
500
+ # : file descriptors (number) (SUSv3)
501
+ # NPROC
502
+ # : number of processes for the user (number) (4.4BSD, GNU/Linux)
503
+ # RSS
504
+ # : resident memory size (bytes) (4.2BSD, GNU/Linux)
505
+ # RTPRIO
506
+ # : ceiling on the process's real-time priority (number) (GNU/Linux)
507
+ # RTTIME
508
+ # : CPU time for real-time process (us) (GNU/Linux)
509
+ # SBSIZE
510
+ # : all socket buffers (bytes) (NetBSD, FreeBSD)
511
+ # SIGPENDING
512
+ # : number of queued signals allowed (signals) (GNU/Linux)
513
+ # STACK
514
+ # : stack size (bytes) (SUSv3)
515
+ #
516
+ #
517
+ # *cur_limit* and *max_limit* may be `:INFINITY`, `"INFINITY"` or
518
+ # Process::RLIM_INFINITY, which means that the resource is not limited. They may
519
+ # be Process::RLIM_SAVED_MAX, Process::RLIM_SAVED_CUR and corresponding symbols
520
+ # and strings too. See system setrlimit(2) manual for details.
521
+ #
522
+ # The following example raises the soft limit of core size to the hard limit to
523
+ # try to make core dump possible.
524
+ #
525
+ # Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1])
526
+ #
527
+ def self.setrlimit: (Symbol | String | Integer resource, Integer cur_limit, ?Integer max_limit) -> nil
528
+
529
+ # Establishes this process as a new session and process group leader, with no
530
+ # controlling tty. Returns the session id. Not available on all platforms.
531
+ #
532
+ # Process.setsid #=> 27422
533
+ #
144
534
  def self.setsid: () -> Integer
145
535
 
146
- # Returns a `Tms` structure (see `Process::Tms` ) that contains user and
147
- # system CPU times for this process, and also for children processes.
148
- #
149
- # ```ruby
150
- # t = Process.times
151
- # [ t.utime, t.stime, t.cutime, t.cstime ] #=> [0.0, 0.02, 0.00, 0.00]
152
- # ```
536
+ # Returns a `Tms` structure (see Process::Tms) that contains user and system CPU
537
+ # times for this process, and also for children processes.
538
+ #
539
+ # t = Process.times
540
+ # [ t.utime, t.stime, t.cutime, t.cstime ] #=> [0.0, 0.02, 0.00, 0.00]
541
+ #
153
542
  def self.times: () -> Process::Tms
154
543
 
155
544
  # Returns the (real) user ID of this process.
156
- #
157
- # ```ruby
158
- # Process.uid #=> 501
159
- # ```
545
+ #
546
+ # Process.uid #=> 501
547
+ #
160
548
  def self.uid: () -> Integer
161
549
 
550
+ # Sets the (user) user ID for this process. Not available on all platforms.
551
+ #
162
552
  def self.uid=: (Integer user) -> Integer
163
553
 
554
+ # Waits for a child process to exit, returns its process id, and sets `$?` to a
555
+ # Process::Status object containing information on that process. Which child it
556
+ # waits on depends on the value of *pid*:
557
+ #
558
+ # > 0
559
+ # : Waits for the child whose process ID equals *pid*.
560
+ #
561
+ # 0
562
+ # : Waits for any child whose process group ID equals that of the calling
563
+ # process.
564
+ #
565
+ # -1
566
+ # : Waits for any child process (the default if no *pid* is given).
567
+ #
568
+ # < -1
569
+ # : Waits for any child whose process group ID equals the absolute value of
570
+ # *pid*.
571
+ #
572
+ #
573
+ # The *flags* argument may be a logical or of the flag values Process::WNOHANG
574
+ # (do not block if no child available) or Process::WUNTRACED (return stopped
575
+ # children that haven't been reported). Not all flags are available on all
576
+ # platforms, but a flag value of zero will work on all platforms.
577
+ #
578
+ # Calling this method raises a SystemCallError if there are no child processes.
579
+ # Not available on all platforms.
580
+ #
581
+ # include Process
582
+ # fork { exit 99 } #=> 27429
583
+ # wait #=> 27429
584
+ # $?.exitstatus #=> 99
585
+ #
586
+ # pid = fork { sleep 3 } #=> 27440
587
+ # Time.now #=> 2008-03-08 19:56:16 +0900
588
+ # waitpid(pid, Process::WNOHANG) #=> nil
589
+ # Time.now #=> 2008-03-08 19:56:16 +0900
590
+ # waitpid(pid, 0) #=> 27440
591
+ # Time.now #=> 2008-03-08 19:56:19 +0900
592
+ #
164
593
  def self.wait: (?Integer pid, ?Integer flags) -> Integer
165
594
 
595
+ # Waits for a child process to exit (see Process::waitpid for exact semantics)
596
+ # and returns an array containing the process id and the exit status (a
597
+ # Process::Status object) of that child. Raises a SystemCallError if there are
598
+ # no child processes.
599
+ #
600
+ # Process.fork { exit 99 } #=> 27437
601
+ # pid, status = Process.wait2
602
+ # pid #=> 27437
603
+ # status.exitstatus #=> 99
604
+ #
166
605
  def self.wait2: (?Integer pid, ?Integer flags) -> [ Integer, Process::Status ]
167
606
 
607
+ # Waits for all children, returning an array of *pid*/*status* pairs (where
608
+ # *status* is a Process::Status object).
609
+ #
610
+ # fork { sleep 0.2; exit 2 } #=> 27432
611
+ # fork { sleep 0.1; exit 1 } #=> 27433
612
+ # fork { exit 0 } #=> 27434
613
+ # p Process.waitall
614
+ #
615
+ # *produces*:
616
+ #
617
+ # [[30982, #<Process::Status: pid 30982 exit 0>],
618
+ # [30979, #<Process::Status: pid 30979 exit 1>],
619
+ # [30976, #<Process::Status: pid 30976 exit 2>]]
620
+ #
168
621
  def self.waitall: () -> ::Array[[ Integer, Process::Status ]]
169
622
 
623
+ # Waits for a child process to exit, returns its process id, and sets `$?` to a
624
+ # Process::Status object containing information on that process. Which child it
625
+ # waits on depends on the value of *pid*:
626
+ #
627
+ # > 0
628
+ # : Waits for the child whose process ID equals *pid*.
629
+ #
630
+ # 0
631
+ # : Waits for any child whose process group ID equals that of the calling
632
+ # process.
633
+ #
634
+ # -1
635
+ # : Waits for any child process (the default if no *pid* is given).
636
+ #
637
+ # < -1
638
+ # : Waits for any child whose process group ID equals the absolute value of
639
+ # *pid*.
640
+ #
641
+ #
642
+ # The *flags* argument may be a logical or of the flag values Process::WNOHANG
643
+ # (do not block if no child available) or Process::WUNTRACED (return stopped
644
+ # children that haven't been reported). Not all flags are available on all
645
+ # platforms, but a flag value of zero will work on all platforms.
646
+ #
647
+ # Calling this method raises a SystemCallError if there are no child processes.
648
+ # Not available on all platforms.
649
+ #
650
+ # include Process
651
+ # fork { exit 99 } #=> 27429
652
+ # wait #=> 27429
653
+ # $?.exitstatus #=> 99
654
+ #
655
+ # pid = fork { sleep 3 } #=> 27440
656
+ # Time.now #=> 2008-03-08 19:56:16 +0900
657
+ # waitpid(pid, Process::WNOHANG) #=> nil
658
+ # Time.now #=> 2008-03-08 19:56:16 +0900
659
+ # waitpid(pid, 0) #=> 27440
660
+ # Time.now #=> 2008-03-08 19:56:19 +0900
661
+ #
170
662
  def self.waitpid: (?Integer pid, ?Integer flags) -> Integer
171
663
 
664
+ # Waits for a child process to exit (see Process::waitpid for exact semantics)
665
+ # and returns an array containing the process id and the exit status (a
666
+ # Process::Status object) of that child. Raises a SystemCallError if there are
667
+ # no child processes.
668
+ #
669
+ # Process.fork { exit 99 } #=> 27437
670
+ # pid, status = Process.wait2
671
+ # pid #=> 27437
672
+ # status.exitstatus #=> 99
673
+ #
172
674
  def self.waitpid2: (?Integer pid, ?Integer flags) -> [ Integer, Process::Status ]
173
675
  end
174
676
 
677
+ # see Process.clock_gettime
678
+ #
679
+ #
175
680
  Process::CLOCK_BOOTTIME: Integer
176
681
 
682
+ # see Process.clock_gettime
683
+ #
684
+ #
177
685
  Process::CLOCK_BOOTTIME_ALARM: Integer
178
686
 
687
+ # see Process.clock_gettime
688
+ #
689
+ #
179
690
  Process::CLOCK_MONOTONIC: Integer
180
691
 
692
+ # see Process.clock_gettime
693
+ #
694
+ #
181
695
  Process::CLOCK_MONOTONIC_COARSE: Integer
182
696
 
697
+ # see Process.clock_gettime
698
+ #
699
+ #
183
700
  Process::CLOCK_MONOTONIC_RAW: Integer
184
701
 
702
+ # see Process.clock_gettime
703
+ #
704
+ #
185
705
  Process::CLOCK_PROCESS_CPUTIME_ID: Integer
186
706
 
707
+ # see Process.clock_gettime
708
+ #
709
+ #
187
710
  Process::CLOCK_REALTIME: Integer
188
711
 
712
+ # see Process.clock_gettime
713
+ #
714
+ #
189
715
  Process::CLOCK_REALTIME_ALARM: Integer
190
716
 
717
+ # see Process.clock_gettime
718
+ #
719
+ #
191
720
  Process::CLOCK_REALTIME_COARSE: Integer
192
721
 
722
+ # see Process.clock_gettime
723
+ #
724
+ #
193
725
  Process::CLOCK_THREAD_CPUTIME_ID: Integer
194
726
 
727
+ # see Process.setpriority
728
+ #
729
+ #
195
730
  Process::PRIO_PGRP: Integer
196
731
 
732
+ # see Process.setpriority
733
+ #
734
+ #
197
735
  Process::PRIO_PROCESS: Integer
198
736
 
737
+ # see Process.setpriority
738
+ #
739
+ #
199
740
  Process::PRIO_USER: Integer
200
741
 
742
+ # Maximum size of the process's virtual memory (address space) in bytes.
743
+ #
744
+ # see the system getrlimit(2) manual for details.
745
+ #
201
746
  Process::RLIMIT_AS: Integer
202
747
 
748
+ # Maximum size of the core file.
749
+ #
750
+ # see the system getrlimit(2) manual for details.
751
+ #
203
752
  Process::RLIMIT_CORE: Integer
204
753
 
754
+ # CPU time limit in seconds.
755
+ #
756
+ # see the system getrlimit(2) manual for details.
757
+ #
205
758
  Process::RLIMIT_CPU: Integer
206
759
 
760
+ # Maximum size of the process's data segment.
761
+ #
762
+ # see the system getrlimit(2) manual for details.
763
+ #
207
764
  Process::RLIMIT_DATA: Integer
208
765
 
766
+ # Maximum size of files that the process may create.
767
+ #
768
+ # see the system getrlimit(2) manual for details.
769
+ #
209
770
  Process::RLIMIT_FSIZE: Integer
210
771
 
772
+ # Maximum number of bytes of memory that may be locked into RAM.
773
+ #
774
+ # see the system getrlimit(2) manual for details.
775
+ #
211
776
  Process::RLIMIT_MEMLOCK: Integer
212
777
 
778
+ # Specifies the limit on the number of bytes that can be allocated for POSIX
779
+ # message queues for the real user ID of the calling process.
780
+ #
781
+ # see the system getrlimit(2) manual for details.
782
+ #
213
783
  Process::RLIMIT_MSGQUEUE: Integer
214
784
 
785
+ # Specifies a ceiling to which the process's nice value can be raised.
786
+ #
787
+ # see the system getrlimit(2) manual for details.
788
+ #
215
789
  Process::RLIMIT_NICE: Integer
216
790
 
791
+ # Specifies a value one greater than the maximum file descriptor number that can
792
+ # be opened by this process.
793
+ #
794
+ # see the system getrlimit(2) manual for details.
795
+ #
217
796
  Process::RLIMIT_NOFILE: Integer
218
797
 
798
+ # The maximum number of processes that can be created for the real user ID of
799
+ # the calling process.
800
+ #
801
+ # see the system getrlimit(2) manual for details.
802
+ #
219
803
  Process::RLIMIT_NPROC: Integer
220
804
 
805
+ # Specifies the limit (in pages) of the process's resident set.
806
+ #
807
+ # see the system getrlimit(2) manual for details.
808
+ #
221
809
  Process::RLIMIT_RSS: Integer
222
810
 
811
+ # Specifies a ceiling on the real-time priority that may be set for this
812
+ # process.
813
+ #
814
+ # see the system getrlimit(2) manual for details.
815
+ #
223
816
  Process::RLIMIT_RTPRIO: Integer
224
817
 
818
+ # Specifies limit on CPU time this process scheduled under a real-time
819
+ # scheduling policy can consume.
820
+ #
821
+ # see the system getrlimit(2) manual for details.
822
+ #
225
823
  Process::RLIMIT_RTTIME: Integer
226
824
 
825
+ # Specifies a limit on the number of signals that may be queued for the real
826
+ # user ID of the calling process.
827
+ #
828
+ # see the system getrlimit(2) manual for details.
829
+ #
227
830
  Process::RLIMIT_SIGPENDING: Integer
228
831
 
832
+ # Maximum size of the stack, in bytes.
833
+ #
834
+ # see the system getrlimit(2) manual for details.
835
+ #
229
836
  Process::RLIMIT_STACK: Integer
230
837
 
838
+ # see Process.setrlimit
839
+ #
840
+ #
231
841
  Process::RLIM_INFINITY: Integer
232
842
 
843
+ # see Process.setrlimit
844
+ #
845
+ #
233
846
  Process::RLIM_SAVED_CUR: Integer
234
847
 
848
+ # see Process.setrlimit
849
+ #
850
+ #
235
851
  Process::RLIM_SAVED_MAX: Integer
236
852
 
853
+ # see Process.wait
854
+ #
855
+ #
237
856
  Process::WNOHANG: Integer
238
857
 
858
+ # see Process.wait
859
+ #
860
+ #
239
861
  Process::WUNTRACED: Integer
240
862
 
863
+ # The Process::GID module contains a collection of module functions which can be
864
+ # used to portably get, set, and switch the current process's real, effective,
865
+ # and saved group IDs.
866
+ #
241
867
  module Process::GID
868
+ # Change the current process's real and effective group ID to that specified by
869
+ # *group*. Returns the new group ID. Not available on all platforms.
870
+ #
871
+ # [Process.gid, Process.egid] #=> [0, 0]
872
+ # Process::GID.change_privilege(33) #=> 33
873
+ # [Process.gid, Process.egid] #=> [33, 33]
874
+ #
242
875
  def self.change_privilege: (Integer group) -> Integer
243
876
 
877
+ # Returns the effective group ID for this process. Not available on all
878
+ # platforms.
879
+ #
880
+ # Process.egid #=> 500
881
+ #
244
882
  def self.eid: () -> Integer
245
883
 
884
+ # Get the group ID by the *name*. If the group is not found, `ArgumentError`
885
+ # will be raised.
886
+ #
887
+ # Process::GID.from_name("wheel") #=> 0
888
+ # Process::GID.from_name("nosuchgroup") #=> can't find group for nosuchgroup (ArgumentError)
889
+ #
246
890
  def self.from_name: (String name) -> Integer
247
891
 
892
+ # Set the effective group ID, and if possible, the saved group ID of the process
893
+ # to the given *group*. Returns the new effective group ID. Not available on all
894
+ # platforms.
895
+ #
896
+ # [Process.gid, Process.egid] #=> [0, 0]
897
+ # Process::GID.grant_privilege(31) #=> 33
898
+ # [Process.gid, Process.egid] #=> [0, 33]
899
+ #
248
900
  def self.grant_privilege: (Integer group) -> Integer
249
901
 
902
+ # Exchange real and effective group IDs and return the new effective group ID.
903
+ # Not available on all platforms.
904
+ #
905
+ # [Process.gid, Process.egid] #=> [0, 33]
906
+ # Process::GID.re_exchange #=> 0
907
+ # [Process.gid, Process.egid] #=> [33, 0]
908
+ #
250
909
  def self.re_exchange: () -> Integer
251
910
 
911
+ # Returns `true` if the real and effective group IDs of a process may be
912
+ # exchanged on the current platform.
913
+ #
252
914
  def self.re_exchangeable?: () -> bool
253
915
 
916
+ # Returns the (real) group ID for this process.
917
+ #
918
+ # Process.gid #=> 500
919
+ #
254
920
  def self.rid: () -> Integer
255
921
 
922
+ # Returns `true` if the current platform has saved group ID functionality.
923
+ #
256
924
  def self.sid_available?: () -> bool
257
925
 
926
+ # Switch the effective and real group IDs of the current process. If a *block*
927
+ # is given, the group IDs will be switched back after the block is executed.
928
+ # Returns the new effective group ID if called without a block, and the return
929
+ # value of the block if one is given.
930
+ #
258
931
  def self.switch: () -> Integer
259
932
  | [T] () { () -> T } -> T
260
933
 
261
934
  def self.eid=: (Integer group) -> Integer
262
935
  end
263
936
 
937
+ # Process::Status encapsulates the information on the status of a running or
938
+ # terminated system process. The built-in variable `$?` is either `nil` or a
939
+ # Process::Status object.
940
+ #
941
+ # fork { exit 99 } #=> 26557
942
+ # Process.wait #=> 26557
943
+ # $?.class #=> Process::Status
944
+ # $?.to_i #=> 25344
945
+ # $? >> 8 #=> 99
946
+ # $?.stopped? #=> false
947
+ # $?.exited? #=> true
948
+ # $?.exitstatus #=> 99
949
+ #
950
+ # Posix systems record information on processes using a 16-bit integer. The
951
+ # lower bits record the process status (stopped, exited, signaled) and the upper
952
+ # bits possibly contain additional information (for example the program's return
953
+ # code in the case of exited processes). Pre Ruby 1.8, these bits were exposed
954
+ # directly to the Ruby program. Ruby now encapsulates these in a Process::Status
955
+ # object. To maximize compatibility, however, these objects retain a
956
+ # bit-oriented interface. In the descriptions that follow, when we talk about
957
+ # the integer value of *stat*, we're referring to this 16 bit value.
958
+ #
264
959
  class Process::Status < Object
960
+ # Logical AND of the bits in *stat* with *num*.
961
+ #
962
+ # fork { exit 0x37 }
963
+ # Process.wait
964
+ # sprintf('%04x', $?.to_i) #=> "3700"
965
+ # sprintf('%04x', $? & 0x1e00) #=> "1600"
966
+ #
265
967
  def &: (Integer num) -> Integer
266
968
 
969
+ # Returns `true` if the integer value of *stat* equals *other*.
970
+ #
267
971
  def ==: (untyped other) -> bool
268
972
 
973
+ # Shift the bits in *stat* right *num* places.
974
+ #
975
+ # fork { exit 99 } #=> 26563
976
+ # Process.wait #=> 26563
977
+ # $?.to_i #=> 25344
978
+ # $? >> 8 #=> 99
979
+ #
269
980
  def >>: (Integer num) -> Integer
270
981
 
982
+ # Returns `true` if *stat* generated a coredump when it terminated. Not
983
+ # available on all platforms.
984
+ #
271
985
  def coredump?: () -> bool
272
986
 
987
+ # Returns `true` if *stat* exited normally (for example using an `exit()` call
988
+ # or finishing the program).
989
+ #
273
990
  def exited?: () -> bool
274
991
 
992
+ # Returns the least significant eight bits of the return code of *stat*. Only
993
+ # available if #exited? is `true`.
994
+ #
995
+ # fork { } #=> 26572
996
+ # Process.wait #=> 26572
997
+ # $?.exited? #=> true
998
+ # $?.exitstatus #=> 0
999
+ #
1000
+ # fork { exit 99 } #=> 26573
1001
+ # Process.wait #=> 26573
1002
+ # $?.exited? #=> true
1003
+ # $?.exitstatus #=> 99
1004
+ #
275
1005
  def exitstatus: () -> Integer?
276
1006
 
1007
+ # Override the inspection method.
1008
+ #
1009
+ # system("false")
1010
+ # p $?.inspect #=> "#<Process::Status: pid 12861 exit 1>"
1011
+ #
277
1012
  def inspect: () -> String
278
1013
 
1014
+ # Returns the process ID that this status object represents.
1015
+ #
1016
+ # fork { exit } #=> 26569
1017
+ # Process.wait #=> 26569
1018
+ # $?.pid #=> 26569
1019
+ #
279
1020
  def pid: () -> Integer
280
1021
 
1022
+ # Returns `true` if *stat* terminated because of an uncaught signal.
1023
+ #
281
1024
  def signaled?: () -> bool
282
1025
 
1026
+ # Returns `true` if this process is stopped. This is only returned if the
1027
+ # corresponding #wait call had the Process::WUNTRACED flag set.
1028
+ #
283
1029
  def stopped?: () -> bool
284
1030
 
1031
+ # Returns the number of the signal that caused *stat* to stop (or `nil` if self
1032
+ # is not stopped).
1033
+ #
285
1034
  def stopsig: () -> Integer?
286
1035
 
1036
+ # Returns `true` if *stat* is successful, `false` if not. Returns `nil` if
1037
+ # #exited? is not `true`.
1038
+ #
287
1039
  def success?: () -> bool
288
1040
 
1041
+ # Returns the number of the signal that caused *stat* to terminate (or `nil` if
1042
+ # self was not terminated by an uncaught signal).
1043
+ #
289
1044
  def termsig: () -> Integer?
290
1045
 
1046
+ # Returns the bits in *stat* as a Integer. Poking around in these bits is
1047
+ # platform dependent.
1048
+ #
1049
+ # fork { exit 0xab } #=> 26566
1050
+ # Process.wait #=> 26566
1051
+ # sprintf('%04x', $?.to_i) #=> "ab00"
1052
+ #
291
1053
  def to_i: () -> Integer
292
1054
 
1055
+ # Show pid and exit status as a string.
1056
+ #
1057
+ # system("false")
1058
+ # p $?.to_s #=> "pid 12766 exit 1"
1059
+ #
293
1060
  def to_s: () -> String
294
1061
  end
295
1062
 
1063
+ # The Process::Sys module contains UID and GID functions which provide direct
1064
+ # bindings to the system calls of the same names instead of the more-portable
1065
+ # versions of the same functionality found in the Process, Process::UID, and
1066
+ # Process::GID modules.
1067
+ #
296
1068
  module Process::Sys
1069
+ # Returns the effective user ID for this process.
1070
+ #
1071
+ # Process.euid #=> 501
1072
+ #
297
1073
  def self.geteuid: () -> Integer
298
1074
 
1075
+ # Returns the (real) group ID for this process.
1076
+ #
1077
+ # Process.gid #=> 500
1078
+ #
299
1079
  def self.getgid: () -> Integer
300
1080
 
1081
+ # Returns the (real) user ID of this process.
1082
+ #
1083
+ # Process.uid #=> 501
1084
+ #
301
1085
  def self.getuid: () -> Integer
302
1086
 
1087
+ # Returns `true` if the process was created as a result of an execve(2) system
1088
+ # call which had either of the setuid or setgid bits set (and extra privileges
1089
+ # were given as a result) or if it has changed any of its real, effective or
1090
+ # saved user or group IDs since it began execution.
1091
+ #
303
1092
  def self.issetugid: () -> bool
304
1093
 
305
- def self.setegid: (Integer group) -> NilClass
306
-
307
- def self.seteuid: (Integer user) -> NilClass
308
-
309
- def self.setgid: (Integer group) -> NilClass
310
-
311
- def self.setregid: (Integer rid, Integer eid) -> NilClass
1094
+ # Set the effective group ID of the calling process to *group*. Not available
1095
+ # on all platforms.
1096
+ #
1097
+ def self.setegid: (Integer group) -> nil
312
1098
 
313
- def self.setresgid: (Integer rid, Integer eid, Integer sid) -> NilClass
1099
+ # Set the effective user ID of the calling process to *user*. Not available on
1100
+ # all platforms.
1101
+ #
1102
+ def self.seteuid: (Integer user) -> nil
314
1103
 
315
- def self.setresuid: (Integer rid, Integer eid, Integer sid) -> NilClass
316
-
317
- def self.setreuid: (Integer rid, Integer eid) -> NilClass
318
-
319
- def self.setrgid: (Integer group) -> NilClass
1104
+ # Set the group ID of the current process to *group*. Not available on all
1105
+ # platforms.
1106
+ #
1107
+ def self.setgid: (Integer group) -> nil
1108
+
1109
+ # Sets the (group) real and/or effective group IDs of the current process to
1110
+ # *rid* and *eid*, respectively. A value of `-1` for either means to leave that
1111
+ # ID unchanged. Not available on all platforms.
1112
+ #
1113
+ def self.setregid: (Integer rid, Integer eid) -> nil
1114
+
1115
+ # Sets the (group) real, effective, and saved user IDs of the current process to
1116
+ # *rid*, *eid*, and *sid* respectively. A value of `-1` for any value means to
1117
+ # leave that ID unchanged. Not available on all platforms.
1118
+ #
1119
+ def self.setresgid: (Integer rid, Integer eid, Integer sid) -> nil
1120
+
1121
+ # Sets the (user) real, effective, and saved user IDs of the current process to
1122
+ # *rid*, *eid*, and *sid* respectively. A value of `-1` for any value means to
1123
+ # leave that ID unchanged. Not available on all platforms.
1124
+ #
1125
+ def self.setresuid: (Integer rid, Integer eid, Integer sid) -> nil
1126
+
1127
+ # Sets the (user) real and/or effective user IDs of the current process to *rid*
1128
+ # and *eid*, respectively. A value of `-1` for either means to leave that ID
1129
+ # unchanged. Not available on all platforms.
1130
+ #
1131
+ def self.setreuid: (Integer rid, Integer eid) -> nil
1132
+
1133
+ # Set the real group ID of the calling process to *group*. Not available on all
1134
+ # platforms.
1135
+ #
1136
+ def self.setrgid: (Integer group) -> nil
320
1137
 
321
- def self.setruid: (Integer user) -> NilClass
1138
+ # Set the real user ID of the calling process to *user*. Not available on all
1139
+ # platforms.
1140
+ #
1141
+ def self.setruid: (Integer user) -> nil
322
1142
 
323
- def self.setuid: (Integer user) -> NilClass
1143
+ # Set the user ID of the current process to *user*. Not available on all
1144
+ # platforms.
1145
+ #
1146
+ def self.setuid: (Integer user) -> nil
324
1147
  end
325
1148
 
1149
+ # The Process::UID module contains a collection of module functions which can be
1150
+ # used to portably get, set, and switch the current process's real, effective,
1151
+ # and saved user IDs.
1152
+ #
326
1153
  module Process::UID
1154
+ # Change the current process's real and effective user ID to that specified by
1155
+ # *user*. Returns the new user ID. Not available on all platforms.
1156
+ #
1157
+ # [Process.uid, Process.euid] #=> [0, 0]
1158
+ # Process::UID.change_privilege(31) #=> 31
1159
+ # [Process.uid, Process.euid] #=> [31, 31]
1160
+ #
327
1161
  def self.change_privilege: (Integer user) -> Integer
328
1162
 
1163
+ # Returns the effective user ID for this process.
1164
+ #
1165
+ # Process.euid #=> 501
1166
+ #
329
1167
  def self.eid: () -> Integer
330
1168
 
1169
+ # Get the user ID by the *name*. If the user is not found, `ArgumentError` will
1170
+ # be raised.
1171
+ #
1172
+ # Process::UID.from_name("root") #=> 0
1173
+ # Process::UID.from_name("nosuchuser") #=> can't find user for nosuchuser (ArgumentError)
1174
+ #
331
1175
  def self.from_name: (String name) -> Integer
332
1176
 
1177
+ # Set the effective user ID, and if possible, the saved user ID of the process
1178
+ # to the given *user*. Returns the new effective user ID. Not available on all
1179
+ # platforms.
1180
+ #
1181
+ # [Process.uid, Process.euid] #=> [0, 0]
1182
+ # Process::UID.grant_privilege(31) #=> 31
1183
+ # [Process.uid, Process.euid] #=> [0, 31]
1184
+ #
333
1185
  def self.grant_privilege: (Integer user) -> Integer
334
1186
 
1187
+ # Exchange real and effective user IDs and return the new effective user ID. Not
1188
+ # available on all platforms.
1189
+ #
1190
+ # [Process.uid, Process.euid] #=> [0, 31]
1191
+ # Process::UID.re_exchange #=> 0
1192
+ # [Process.uid, Process.euid] #=> [31, 0]
1193
+ #
335
1194
  def self.re_exchange: () -> Integer
336
1195
 
1196
+ # Returns `true` if the real and effective user IDs of a process may be
1197
+ # exchanged on the current platform.
1198
+ #
337
1199
  def self.re_exchangeable?: () -> bool
338
1200
 
1201
+ # Returns the (real) user ID of this process.
1202
+ #
1203
+ # Process.uid #=> 501
1204
+ #
339
1205
  def self.rid: () -> Integer
340
1206
 
1207
+ # Returns `true` if the current platform has saved user ID functionality.
1208
+ #
341
1209
  def self.sid_available?: () -> bool
342
1210
 
1211
+ # Switch the effective and real user IDs of the current process. If a *block* is
1212
+ # given, the user IDs will be switched back after the block is executed. Returns
1213
+ # the new effective user ID if called without a block, and the return value of
1214
+ # the block if one is given.
1215
+ #
343
1216
  def self.switch: () -> Integer
344
1217
  | [T] () { () -> T } -> T
345
1218