rbs 4.0.0.dev.5 → 4.0.1.dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.clang-format +1 -0
- data/.github/workflows/c-check.yml +8 -4
- data/.github/workflows/comments.yml +3 -1
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +10 -0
- data/.github/workflows/rust.yml +95 -0
- data/CHANGELOG.md +323 -0
- data/Rakefile +12 -29
- data/Steepfile +1 -0
- data/config.yml +393 -37
- data/core/array.rbs +218 -188
- data/core/basic_object.rbs +9 -8
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +45 -31
- data/core/complex.rbs +52 -40
- data/core/dir.rbs +57 -45
- data/core/encoding.rbs +5 -5
- data/core/enumerable.rbs +96 -91
- data/core/enumerator.rbs +4 -3
- data/core/errno.rbs +3 -2
- data/core/errors.rbs +31 -29
- data/core/exception.rbs +12 -12
- data/core/fiber.rbs +36 -36
- data/core/file.rbs +186 -113
- data/core/file_test.rbs +2 -2
- data/core/float.rbs +41 -32
- data/core/gc.rbs +78 -70
- data/core/hash.rbs +70 -60
- data/core/integer.rbs +32 -28
- data/core/io/buffer.rbs +36 -36
- data/core/io/wait.rbs +7 -7
- data/core/io.rbs +120 -135
- data/core/kernel.rbs +189 -139
- data/core/marshal.rbs +3 -3
- data/core/match_data.rbs +14 -12
- data/core/math.rbs +69 -67
- data/core/method.rbs +6 -6
- data/core/module.rbs +146 -85
- data/core/nil_class.rbs +4 -3
- data/core/numeric.rbs +35 -32
- data/core/object.rbs +6 -8
- data/core/object_space.rbs +11 -10
- data/core/pathname.rbs +131 -81
- data/core/proc.rbs +65 -33
- data/core/process.rbs +219 -201
- data/core/ractor.rbs +15 -11
- data/core/random.rbs +4 -3
- data/core/range.rbs +52 -47
- data/core/rational.rbs +5 -5
- data/core/rbs/unnamed/argf.rbs +58 -51
- data/core/rbs/unnamed/env_class.rbs +18 -13
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +7 -5
- data/core/regexp.rbs +236 -197
- data/core/ruby.rbs +1 -1
- data/core/ruby_vm.rbs +32 -30
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +1 -1
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +5 -3
- data/core/set.rbs +17 -16
- data/core/signal.rbs +2 -2
- data/core/string.rbs +311 -292
- data/core/struct.rbs +26 -25
- data/core/symbol.rbs +25 -24
- data/core/thread.rbs +40 -34
- data/core/time.rbs +47 -42
- data/core/trace_point.rbs +34 -31
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +10 -10
- data/core/warning.rbs +7 -7
- data/docs/collection.md +1 -1
- data/docs/config.md +171 -0
- data/docs/inline.md +110 -4
- data/docs/syntax.md +13 -12
- data/ext/rbs_extension/ast_translation.c +489 -135
- data/ext/rbs_extension/class_constants.c +8 -0
- data/ext/rbs_extension/class_constants.h +4 -0
- data/ext/rbs_extension/legacy_location.c +28 -51
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +12 -20
- data/include/rbs/ast.h +423 -195
- data/include/rbs/lexer.h +2 -2
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +2 -2
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/ruby/annotations.rb +157 -4
- data/lib/rbs/ast/ruby/members.rb +374 -22
- data/lib/rbs/cli/validate.rb +5 -60
- data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
- data/lib/rbs/definition_builder.rb +60 -27
- data/lib/rbs/errors.rb +0 -11
- data/lib/rbs/inline_parser.rb +1 -1
- data/lib/rbs/parser_aux.rb +20 -7
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +1 -26
- data/lib/rbs/prototype/rbi.rb +1 -20
- data/lib/rbs/test/type_check.rb +3 -0
- data/lib/rbs/types.rb +62 -52
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +0 -1
- data/rbs.gemspec +1 -1
- data/rust/.gitignore +1 -0
- data/rust/Cargo.lock +378 -0
- data/rust/Cargo.toml +7 -0
- data/rust/ruby-rbs/Cargo.toml +22 -0
- data/rust/ruby-rbs/build.rs +764 -0
- data/rust/ruby-rbs/examples/locations.rs +60 -0
- data/rust/ruby-rbs/src/lib.rs +1 -0
- data/rust/ruby-rbs/src/node/mod.rs +742 -0
- data/rust/ruby-rbs/tests/sanity.rs +47 -0
- data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
- data/rust/ruby-rbs-sys/Cargo.toml +23 -0
- data/rust/ruby-rbs-sys/build.rs +204 -0
- data/rust/ruby-rbs-sys/src/lib.rs +50 -0
- data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
- data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
- data/rust/ruby-rbs-sys/wrapper.h +1 -0
- data/sig/ast/ruby/annotations.rbs +191 -4
- data/sig/ast/ruby/members.rbs +21 -1
- data/sig/cli/validate.rbs +1 -6
- data/sig/definition_builder.rbs +2 -0
- data/sig/errors.rbs +0 -8
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +17 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/types.rbs +10 -11
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +339 -161
- data/src/lexstate.c +1 -1
- data/src/location.c +7 -47
- data/src/parser.c +674 -480
- data/src/util/rbs_constant_pool.c +0 -4
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
- data/stdlib/cgi-escape/0/escape.rbs +4 -4
- data/stdlib/coverage/0/coverage.rbs +4 -3
- data/stdlib/date/0/date.rbs +33 -28
- data/stdlib/date/0/date_time.rbs +24 -23
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/erb/0/erb.rbs +64 -53
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +138 -125
- data/stdlib/forwardable/0/forwardable.rbs +10 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +135 -108
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +159 -134
- data/stdlib/objspace/0/objspace.rbs +8 -7
- data/stdlib/open-uri/0/open-uri.rbs +8 -8
- data/stdlib/open3/0/open3.rbs +36 -35
- data/stdlib/openssl/0/openssl.rbs +144 -129
- data/stdlib/optparse/0/optparse.rbs +18 -14
- data/stdlib/pathname/0/pathname.rbs +2 -2
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +61 -8
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
- data/stdlib/ripper/0/ripper.rbs +20 -17
- data/stdlib/securerandom/0/securerandom.rbs +1 -1
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/socket/0/addrinfo.rbs +7 -7
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +10 -9
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +1 -1
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +55 -54
- data/stdlib/strscan/0/string_scanner.rbs +46 -44
- data/stdlib/tempfile/0/tempfile.rbs +24 -20
- data/stdlib/time/0/time.rbs +7 -5
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +26 -18
- data/stdlib/uri/0/file.rbs +2 -2
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_reader.rbs +4 -4
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- metadata +23 -5
- data/.github/workflows/valgrind.yml +0 -42
data/core/process.rbs
CHANGED
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
# What the word "executable" means here is depending on platforms.
|
|
99
99
|
#
|
|
100
100
|
# Even if the file considered "executable", its content may not be in proper
|
|
101
|
-
# executable format. In that case, Ruby tries to run it by using
|
|
102
|
-
# on a Unix-like system, like system(3) does.
|
|
101
|
+
# executable format. In that case, Ruby tries to run it by using
|
|
102
|
+
# <code>/bin/sh</code> on a Unix-like system, like system(3) does.
|
|
103
103
|
#
|
|
104
104
|
# File.write('shell_command', 'echo $SHELL', perm: 0o755)
|
|
105
105
|
# system('./shell_command') # prints "/bin/sh" or something.
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
#
|
|
158
158
|
# Optional trailing argument `options` is a hash of execution options.
|
|
159
159
|
#
|
|
160
|
-
# #### Working Directory (
|
|
160
|
+
# #### Working Directory (<code>:chdir</code>)
|
|
161
161
|
#
|
|
162
162
|
# By default, the working directory for the new process is the same as that of
|
|
163
163
|
# the current process:
|
|
@@ -169,7 +169,8 @@
|
|
|
169
169
|
#
|
|
170
170
|
# /var
|
|
171
171
|
#
|
|
172
|
-
# Use option
|
|
172
|
+
# Use option <code>:chdir</code> to set the working directory for the new
|
|
173
|
+
# process:
|
|
173
174
|
#
|
|
174
175
|
# Process.spawn('ruby -e "puts Dir.pwd"', {chdir: '/tmp'})
|
|
175
176
|
#
|
|
@@ -194,42 +195,43 @@
|
|
|
194
195
|
#
|
|
195
196
|
# There are these shorthand symbols for fds:
|
|
196
197
|
#
|
|
197
|
-
# *
|
|
198
|
-
# *
|
|
199
|
-
# *
|
|
198
|
+
# * <code>:in</code>: Specifies file descriptor 0 (STDIN).
|
|
199
|
+
# * <code>:out</code>: Specifies file descriptor 1 (STDOUT).
|
|
200
|
+
# * <code>:err</code>: Specifies file descriptor 2 (STDERR).
|
|
200
201
|
#
|
|
201
202
|
# The value given with a source is one of:
|
|
202
203
|
#
|
|
203
204
|
# * *n*: Redirects to fd *n* in the parent process.
|
|
204
205
|
# * `filepath`: Redirects from or to the file at `filepath` via
|
|
205
|
-
#
|
|
206
|
-
#
|
|
207
|
-
#
|
|
208
|
-
#
|
|
209
|
-
#
|
|
210
|
-
#
|
|
211
|
-
#
|
|
212
|
-
#
|
|
213
|
-
#
|
|
214
|
-
# *
|
|
206
|
+
# <code>open(filepath, mode, 0644)</code>, where `mode` is <code>'r'</code>
|
|
207
|
+
# for source <code>:in</code>, or <code>'w'</code> for source
|
|
208
|
+
# <code>:out</code> or <code>:err</code>.
|
|
209
|
+
# * <code>[filepath]</code>: Redirects from the file at `filepath` via
|
|
210
|
+
# <code>open(filepath, 'r', 0644)</code>.
|
|
211
|
+
# * <code>[filepath, mode]</code>: Redirects from or to the file at `filepath`
|
|
212
|
+
# via <code>open(filepath, mode, 0644)</code>.
|
|
213
|
+
# * <code>[filepath, mode, perm]</code>: Redirects from or to the file at
|
|
214
|
+
# `filepath` via <code>open(filepath, mode, perm)</code>.
|
|
215
|
+
# * <code>[:child, fd]</code>: Redirects to the redirected `fd`.
|
|
216
|
+
# * <code>:close</code>: Closes the file descriptor in child process.
|
|
215
217
|
#
|
|
216
218
|
# See [Access Modes](rdoc-ref:File@Access+Modes) and [File
|
|
217
219
|
# Permissions](rdoc-ref:File@File+Permissions).
|
|
218
220
|
#
|
|
219
|
-
# #### Environment Variables (
|
|
221
|
+
# #### Environment Variables (<code>:unsetenv_others</code>)
|
|
220
222
|
#
|
|
221
223
|
# By default, the new process inherits environment variables from the parent
|
|
222
|
-
# process; use execution option key
|
|
223
|
-
# clear environment variables in the new process.
|
|
224
|
+
# process; use execution option key <code>:unsetenv_others</code> with value
|
|
225
|
+
# `true` to clear environment variables in the new process.
|
|
224
226
|
#
|
|
225
227
|
# Any changes specified by execution option `env` are made after the new process
|
|
226
228
|
# inherits or clears its environment variables; see [Execution
|
|
227
229
|
# Environment](rdoc-ref:Process@Execution+Environment).
|
|
228
230
|
#
|
|
229
|
-
# #### File-Creation Access (
|
|
231
|
+
# #### File-Creation Access (<code>:umask</code>)
|
|
230
232
|
#
|
|
231
|
-
# Use execution option
|
|
232
|
-
# process; see [Access Modes](rdoc-ref:File@Access+Modes):
|
|
233
|
+
# Use execution option <code>:umask</code> to set the file-creation access for
|
|
234
|
+
# the new process; see [Access Modes](rdoc-ref:File@Access+Modes):
|
|
233
235
|
#
|
|
234
236
|
# command = 'ruby -e "puts sprintf(\"0%o\", File.umask)"'
|
|
235
237
|
# options = {:umask => 0644}
|
|
@@ -239,28 +241,29 @@
|
|
|
239
241
|
#
|
|
240
242
|
# 0644
|
|
241
243
|
#
|
|
242
|
-
# #### Process Groups (
|
|
244
|
+
# #### Process Groups (<code>:pgroup</code> and <code>:new_pgroup</code>)
|
|
243
245
|
#
|
|
244
246
|
# By default, the new process belongs to the same [process
|
|
245
247
|
# group](https://en.wikipedia.org/wiki/Process_group) as the parent process.
|
|
246
248
|
#
|
|
247
|
-
# To specify a different process group. use execution option
|
|
248
|
-
# of the following values:
|
|
249
|
+
# To specify a different process group. use execution option
|
|
250
|
+
# <code>:pgroup</code> with one of the following values:
|
|
249
251
|
#
|
|
250
252
|
# * `true`: Create a new process group for the new process.
|
|
251
253
|
# * *pgid*: Create the new process in the process group whose id is *pgid*.
|
|
252
254
|
#
|
|
253
|
-
# On Windows only, use execution option
|
|
254
|
-
# create a new process group for the new process.
|
|
255
|
+
# On Windows only, use execution option <code>:new_pgroup</code> with value
|
|
256
|
+
# `true` to create a new process group for the new process.
|
|
255
257
|
#
|
|
256
258
|
# #### Resource Limits
|
|
257
259
|
#
|
|
258
260
|
# Use execution options to set resource limits.
|
|
259
261
|
#
|
|
260
|
-
# The keys for these options are symbols of the form
|
|
261
|
-
# where *resource_name* is the
|
|
262
|
-
#
|
|
263
|
-
#
|
|
262
|
+
# The keys for these options are symbols of the form
|
|
263
|
+
# <code>:rlimit_<i>resource_name</i></code>, where *resource_name* is the
|
|
264
|
+
# downcased form of one of the string resource names described at method
|
|
265
|
+
# Process.setrlimit. For example, key <code>:rlimit_cpu</code> corresponds to
|
|
266
|
+
# resource limit <code>'CPU'</code>.
|
|
264
267
|
#
|
|
265
268
|
# The value for such as key is one of:
|
|
266
269
|
#
|
|
@@ -271,13 +274,14 @@
|
|
|
271
274
|
#
|
|
272
275
|
# By default, the new process inherits file descriptors from the parent process.
|
|
273
276
|
#
|
|
274
|
-
# Use execution option
|
|
275
|
-
# closing non-standard fds (3 and greater) that are not otherwise
|
|
277
|
+
# Use execution option <code>:close_others => true</code> to modify that
|
|
278
|
+
# inheritance by closing non-standard fds (3 and greater) that are not otherwise
|
|
279
|
+
# redirected.
|
|
276
280
|
#
|
|
277
281
|
# ### Execution Shell
|
|
278
282
|
#
|
|
279
|
-
# On a Unix-like system, the shell invoked is
|
|
280
|
-
# `command_line` is passed as an argument to [shell option
|
|
283
|
+
# On a Unix-like system, the shell invoked is <code>/bin/sh</code>; the entire
|
|
284
|
+
# string `command_line` is passed as an argument to [shell option
|
|
281
285
|
# -c](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh.
|
|
282
286
|
# html).
|
|
283
287
|
#
|
|
@@ -295,21 +299,23 @@
|
|
|
295
299
|
#
|
|
296
300
|
# On Windows, the shell invoked is determined by environment variable
|
|
297
301
|
# `RUBYSHELL`, if defined, or `COMSPEC` otherwise; the entire string
|
|
298
|
-
# `command_line` is passed as an argument to
|
|
299
|
-
# well as
|
|
302
|
+
# `command_line` is passed as an argument to <code>-c</code> option for
|
|
303
|
+
# `RUBYSHELL`, as well as <code>/bin/sh</code>, and [/c
|
|
300
304
|
# option](https://learn.microsoft.com/en-us/windows-server/administration/window
|
|
301
305
|
# s-commands/cmd) for `COMSPEC`. The shell is invoked automatically in the
|
|
302
306
|
# following cases:
|
|
303
307
|
#
|
|
304
|
-
# * The command is a built-in of
|
|
305
|
-
# * The executable file is a batch file; its name ends with
|
|
308
|
+
# * The command is a built-in of <code>cmd.exe</code>, such as `echo`.
|
|
309
|
+
# * The executable file is a batch file; its name ends with <code>.bat</code>
|
|
310
|
+
# or <code>.cmd</code>.
|
|
306
311
|
#
|
|
307
312
|
# Note that the command will still be invoked as `command_line` form even when
|
|
308
|
-
# called in `exe_path` form, because
|
|
309
|
-
# like
|
|
313
|
+
# called in `exe_path` form, because <code>cmd.exe</code> does not accept a
|
|
314
|
+
# script name like <code>/bin/sh</code> does but only works with <code>/c</code>
|
|
315
|
+
# option.
|
|
310
316
|
#
|
|
311
|
-
# The standard shell
|
|
312
|
-
# not have globbing functionality:
|
|
317
|
+
# The standard shell <code>cmd.exe</code> performs environment variable
|
|
318
|
+
# expansion but does not have globbing functionality:
|
|
313
319
|
#
|
|
314
320
|
# Example:
|
|
315
321
|
#
|
|
@@ -405,7 +411,7 @@ module Process
|
|
|
405
411
|
# - Process._fork -> integer
|
|
406
412
|
# -->
|
|
407
413
|
# An internal API for fork. Do not call this method directly. Currently, this is
|
|
408
|
-
# called via Kernel#fork, Process.fork, and IO.popen with
|
|
414
|
+
# called via Kernel#fork, Process.fork, and IO.popen with <code>"-"</code>.
|
|
409
415
|
#
|
|
410
416
|
# This method is not for casual code but for application monitoring libraries.
|
|
411
417
|
# You can add custom code before and after fork events by overriding this
|
|
@@ -453,17 +459,17 @@ module Process
|
|
|
453
459
|
# Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :second) # => 0
|
|
454
460
|
#
|
|
455
461
|
# In addition to the values for `unit` supported in Process.clock_gettime, this
|
|
456
|
-
# method supports
|
|
457
|
-
# is the reciprocal of
|
|
462
|
+
# method supports <code>:hertz</code>, the integer number of clock ticks per
|
|
463
|
+
# second (which is the reciprocal of <code>:float_second</code>):
|
|
458
464
|
#
|
|
459
465
|
# Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) # => 100.0
|
|
460
466
|
# Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :float_second) # => 0.01
|
|
461
467
|
#
|
|
462
468
|
# **Accuracy**: Note that the returned resolution may be inaccurate on some
|
|
463
469
|
# platforms due to underlying bugs. Inaccurate resolutions have been reported
|
|
464
|
-
# for various clocks including
|
|
465
|
-
# Linux, macOS, BSD or AIX platforms, when
|
|
466
|
-
# virtualization.
|
|
470
|
+
# for various clocks including <code>:CLOCK_MONOTONIC</code> and
|
|
471
|
+
# <code>:CLOCK_MONOTONIC_RAW</code> on Linux, macOS, BSD or AIX platforms, when
|
|
472
|
+
# using ARM processors, or when using virtualization.
|
|
467
473
|
#
|
|
468
474
|
def self.clock_getres: (Symbol | Integer clock_id, ?Symbol unit) -> (Float | Integer)
|
|
469
475
|
|
|
@@ -482,74 +488,77 @@ module Process
|
|
|
482
488
|
# Optional argument `unit` should be a symbol that specifies the unit to be used
|
|
483
489
|
# in the returned clock time; see below.
|
|
484
490
|
#
|
|
485
|
-
#
|
|
491
|
+
# <strong>Argument `clock_id`</strong>
|
|
486
492
|
#
|
|
487
493
|
# Argument `clock_id` specifies the clock whose time is to be returned; it may
|
|
488
|
-
# be a constant such as
|
|
489
|
-
#
|
|
494
|
+
# be a constant such as <code>Process::CLOCK_REALTIME</code>, or a symbol
|
|
495
|
+
# shorthand such as <code>:CLOCK_REALTIME</code>.
|
|
490
496
|
#
|
|
491
497
|
# The supported clocks depend on the underlying operating system; this method
|
|
492
498
|
# supports the following clocks on the indicated platforms (raises Errno::EINVAL
|
|
493
499
|
# if called with an unsupported clock):
|
|
494
500
|
#
|
|
495
|
-
# *
|
|
496
|
-
# *
|
|
497
|
-
# *
|
|
498
|
-
# OpenBSD 3.4, macOS 10.12, Windows-2000.
|
|
499
|
-
# *
|
|
500
|
-
# *
|
|
501
|
-
# *
|
|
502
|
-
# *
|
|
503
|
-
# *
|
|
504
|
-
# *
|
|
505
|
-
# OpenBSD 5.4, macOS 10.12.
|
|
506
|
-
# *
|
|
507
|
-
# *
|
|
508
|
-
# OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012. Time.now is
|
|
509
|
-
# over +:CLOCK_REALTIME:.
|
|
510
|
-
# *
|
|
511
|
-
# *
|
|
512
|
-
# *
|
|
513
|
-
# *
|
|
514
|
-
# *
|
|
515
|
-
# *
|
|
516
|
-
# *
|
|
517
|
-
# 5.4, macOS 10.12.
|
|
518
|
-
# *
|
|
519
|
-
# *
|
|
520
|
-
# *
|
|
521
|
-
# *
|
|
522
|
-
# *
|
|
523
|
-
# *
|
|
501
|
+
# * <code>:CLOCK_BOOTTIME</code>: Linux 2.6.39.
|
|
502
|
+
# * <code>:CLOCK_BOOTTIME_ALARM</code>: Linux 3.0.
|
|
503
|
+
# * <code>:CLOCK_MONOTONIC</code>: SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0,
|
|
504
|
+
# NetBSD 2.0, OpenBSD 3.4, macOS 10.12, Windows-2000.
|
|
505
|
+
# * <code>:CLOCK_MONOTONIC_COARSE</code>: Linux 2.6.32.
|
|
506
|
+
# * <code>:CLOCK_MONOTONIC_FAST</code>: FreeBSD 8.1.
|
|
507
|
+
# * <code>:CLOCK_MONOTONIC_PRECISE</code>: FreeBSD 8.1.
|
|
508
|
+
# * <code>:CLOCK_MONOTONIC_RAW</code>: Linux 2.6.28, macOS 10.12.
|
|
509
|
+
# * <code>:CLOCK_MONOTONIC_RAW_APPROX</code>: macOS 10.12.
|
|
510
|
+
# * <code>:CLOCK_PROCESS_CPUTIME_ID</code>: SUSv3 to 4, Linux 2.5.63, FreeBSD
|
|
511
|
+
# 9.3, OpenBSD 5.4, macOS 10.12.
|
|
512
|
+
# * <code>:CLOCK_PROF</code>: FreeBSD 3.0, OpenBSD 2.1.
|
|
513
|
+
# * <code>:CLOCK_REALTIME</code>: SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0,
|
|
514
|
+
# NetBSD 2.0, OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012. Time.now is
|
|
515
|
+
# recommended over +:CLOCK_REALTIME:.
|
|
516
|
+
# * <code>:CLOCK_REALTIME_ALARM</code>: Linux 3.0.
|
|
517
|
+
# * <code>:CLOCK_REALTIME_COARSE</code>: Linux 2.6.32.
|
|
518
|
+
# * <code>:CLOCK_REALTIME_FAST</code>: FreeBSD 8.1.
|
|
519
|
+
# * <code>:CLOCK_REALTIME_PRECISE</code>: FreeBSD 8.1.
|
|
520
|
+
# * <code>:CLOCK_SECOND</code>: FreeBSD 8.1.
|
|
521
|
+
# * <code>:CLOCK_TAI</code>: Linux 3.10.
|
|
522
|
+
# * <code>:CLOCK_THREAD_CPUTIME_ID</code>: SUSv3 to 4, Linux 2.5.63, FreeBSD
|
|
523
|
+
# 7.1, OpenBSD 5.4, macOS 10.12.
|
|
524
|
+
# * <code>:CLOCK_UPTIME</code>: FreeBSD 7.0, OpenBSD 5.5.
|
|
525
|
+
# * <code>:CLOCK_UPTIME_FAST</code>: FreeBSD 8.1.
|
|
526
|
+
# * <code>:CLOCK_UPTIME_PRECISE</code>: FreeBSD 8.1.
|
|
527
|
+
# * <code>:CLOCK_UPTIME_RAW</code>: macOS 10.12.
|
|
528
|
+
# * <code>:CLOCK_UPTIME_RAW_APPROX</code>: macOS 10.12.
|
|
529
|
+
# * <code>:CLOCK_VIRTUAL</code>: FreeBSD 3.0, OpenBSD 2.1.
|
|
524
530
|
#
|
|
525
531
|
# Note that SUS stands for Single Unix Specification. SUS contains POSIX and
|
|
526
|
-
# clock_gettime is defined in the POSIX part. SUS defines
|
|
527
|
-
# mandatory but
|
|
528
|
-
#
|
|
532
|
+
# clock_gettime is defined in the POSIX part. SUS defines
|
|
533
|
+
# <code>:CLOCK_REALTIME</code> as mandatory but <code>:CLOCK_MONOTONIC</code>,
|
|
534
|
+
# <code>:CLOCK_PROCESS_CPUTIME_ID</code>, and
|
|
535
|
+
# <code>:CLOCK_THREAD_CPUTIME_ID</code> are optional.
|
|
529
536
|
#
|
|
530
537
|
# Certain emulations are used when the given `clock_id` is not supported
|
|
531
538
|
# directly:
|
|
532
539
|
#
|
|
533
|
-
# * Emulations for
|
|
540
|
+
# * Emulations for <code>:CLOCK_REALTIME</code>:
|
|
534
541
|
#
|
|
535
|
-
# *
|
|
536
|
-
# SUS (deprecated in SUSv4). The resolution is 1 microsecond.
|
|
537
|
-
# *
|
|
538
|
-
# resolution is 1 second.
|
|
542
|
+
# * <code>:GETTIMEOFDAY_BASED_CLOCK_REALTIME</code>: Use gettimeofday()
|
|
543
|
+
# defined by SUS (deprecated in SUSv4). The resolution is 1 microsecond.
|
|
544
|
+
# * <code>:TIME_BASED_CLOCK_REALTIME</code>: Use time() defined by ISO C.
|
|
545
|
+
# The resolution is 1 second.
|
|
539
546
|
#
|
|
540
|
-
# * Emulations for
|
|
547
|
+
# * Emulations for <code>:CLOCK_MONOTONIC</code>:
|
|
541
548
|
#
|
|
542
|
-
# *
|
|
543
|
-
# available on Darwin. The resolution is CPU
|
|
544
|
-
#
|
|
545
|
-
#
|
|
549
|
+
# * <code>:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC</code>: Use
|
|
550
|
+
# mach_absolute_time(), available on Darwin. The resolution is CPU
|
|
551
|
+
# dependent.
|
|
552
|
+
# * <code>:TIMES_BASED_CLOCK_MONOTONIC</code>: Use the result value of
|
|
553
|
+
# times() defined by POSIX, thus:
|
|
546
554
|
# > Upon successful completion, times() shall return the elapsed real
|
|
547
555
|
# time, in clock ticks, since an arbitrary point in the past (for
|
|
548
556
|
# example, system start-up time).
|
|
549
557
|
#
|
|
550
558
|
# > For example, GNU/Linux returns a value based on jiffies and it is
|
|
551
559
|
# monotonic. However, 4.4BSD uses gettimeofday() and it is not
|
|
552
|
-
# monotonic. (FreeBSD uses
|
|
560
|
+
# monotonic. (FreeBSD uses <code>:CLOCK_MONOTONIC</code> instead,
|
|
561
|
+
# though.)
|
|
553
562
|
#
|
|
554
563
|
# The resolution is the clock tick. "getconf CLK_TCK" command shows the
|
|
555
564
|
# clock ticks per second. (The clock ticks-per-second is defined by HZ
|
|
@@ -557,40 +566,40 @@ module Process
|
|
|
557
566
|
# type, the resolution is 10 millisecond and cannot represent over 497
|
|
558
567
|
# days.
|
|
559
568
|
#
|
|
560
|
-
# * Emulations for
|
|
561
|
-
#
|
|
562
|
-
# *
|
|
563
|
-
# by SUS. getrusage() is used with RUSAGE_SELF to
|
|
564
|
-
# for the calling process (excluding the time for
|
|
565
|
-
# result is addition of user time (ru_utime) and
|
|
566
|
-
# The resolution is 1 microsecond.
|
|
567
|
-
# *
|
|
568
|
-
# The result is addition of user time (tms_utime) and
|
|
569
|
-
# (tms_stime). tms_cutime and tms_cstime are ignored to
|
|
570
|
-
# for child processes. The resolution is the clock
|
|
571
|
-
# CLK_TCK" command shows the clock ticks per second. (The
|
|
572
|
-
# per second is defined by HZ macro in older systems.) If it
|
|
573
|
-
# resolution is 10 millisecond.
|
|
574
|
-
# *
|
|
575
|
-
# The resolution is
|
|
576
|
-
# macro defined by time.h. SUS defines
|
|
577
|
-
# other systems may define it differently.
|
|
578
|
-
# 1000000 (as in SUS), the resolution is 1
|
|
579
|
-
# `CLOCKS_PER_SEC` is 1000000 and clock_t is a 32-bit
|
|
580
|
-
# cannot represent over 72 minutes.
|
|
581
|
-
#
|
|
582
|
-
#
|
|
583
|
-
#
|
|
584
|
-
# Optional argument `unit` (default
|
|
585
|
-
# returned value.
|
|
586
|
-
#
|
|
587
|
-
# *
|
|
588
|
-
# *
|
|
589
|
-
# *
|
|
590
|
-
# *
|
|
591
|
-
# *
|
|
592
|
-
# *
|
|
593
|
-
# *
|
|
569
|
+
# * Emulations for <code>:CLOCK_PROCESS_CPUTIME_ID</code>:
|
|
570
|
+
#
|
|
571
|
+
# * <code>:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID</code>: Use
|
|
572
|
+
# getrusage() defined by SUS. getrusage() is used with RUSAGE_SELF to
|
|
573
|
+
# obtain the time only for the calling process (excluding the time for
|
|
574
|
+
# child processes). The result is addition of user time (ru_utime) and
|
|
575
|
+
# system time (ru_stime). The resolution is 1 microsecond.
|
|
576
|
+
# * <code>:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID</code>: Use times()
|
|
577
|
+
# defined by POSIX. The result is addition of user time (tms_utime) and
|
|
578
|
+
# system time (tms_stime). tms_cutime and tms_cstime are ignored to
|
|
579
|
+
# exclude the time for child processes. The resolution is the clock
|
|
580
|
+
# tick. "getconf CLK_TCK" command shows the clock ticks per second. (The
|
|
581
|
+
# clock ticks per second is defined by HZ macro in older systems.) If it
|
|
582
|
+
# is 100, the resolution is 10 millisecond.
|
|
583
|
+
# * <code>:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID</code>: Use clock()
|
|
584
|
+
# defined by ISO C. The resolution is <code>1/CLOCKS_PER_SEC</code>.
|
|
585
|
+
# `CLOCKS_PER_SEC` is the C-level macro defined by time.h. SUS defines
|
|
586
|
+
# `CLOCKS_PER_SEC` as 1000000; other systems may define it differently.
|
|
587
|
+
# If `CLOCKS_PER_SEC` is 1000000 (as in SUS), the resolution is 1
|
|
588
|
+
# microsecond. If `CLOCKS_PER_SEC` is 1000000 and clock_t is a 32-bit
|
|
589
|
+
# integer type, it cannot represent over 72 minutes.
|
|
590
|
+
#
|
|
591
|
+
# <strong>Argument `unit`</strong>
|
|
592
|
+
#
|
|
593
|
+
# Optional argument `unit` (default <code>:float_second</code>) specifies the
|
|
594
|
+
# unit for the returned value.
|
|
595
|
+
#
|
|
596
|
+
# * <code>:float_microsecond</code>: Number of microseconds as a float.
|
|
597
|
+
# * <code>:float_millisecond</code>: Number of milliseconds as a float.
|
|
598
|
+
# * <code>:float_second</code>: Number of seconds as a float.
|
|
599
|
+
# * <code>:microsecond</code>: Number of microseconds as an integer.
|
|
600
|
+
# * <code>:millisecond</code>: Number of milliseconds as an integer.
|
|
601
|
+
# * <code>:nanosecond</code>: Number of nanoseconds as an integer.
|
|
602
|
+
# * <code>:second</code>: Number of seconds as an integer.
|
|
594
603
|
#
|
|
595
604
|
# Examples:
|
|
596
605
|
#
|
|
@@ -611,15 +620,15 @@ module Process
|
|
|
611
620
|
#
|
|
612
621
|
# The underlying function, clock_gettime(), returns a number of nanoseconds.
|
|
613
622
|
# Float object (IEEE 754 double) is not enough to represent the return value for
|
|
614
|
-
#
|
|
615
|
-
#
|
|
623
|
+
# <code>:CLOCK_REALTIME</code>. If the exact nanoseconds value is required, use
|
|
624
|
+
# <code>:nanosecond</code> as the `unit`.
|
|
616
625
|
#
|
|
617
626
|
# The origin (time zero) of the returned value is system-dependent, and may be,
|
|
618
627
|
# for example, system start up time, process start up time, the Epoch, etc.
|
|
619
628
|
#
|
|
620
|
-
# The origin in
|
|
621
|
-
# UTC
|
|
622
|
-
# across systems.
|
|
629
|
+
# The origin in <code>:CLOCK_REALTIME</code> is defined as the Epoch:
|
|
630
|
+
# <code>1970-01-01 00:00:00 UTC</code>; some systems count leap seconds and
|
|
631
|
+
# others don't, so the result may vary across systems.
|
|
623
632
|
#
|
|
624
633
|
def self.clock_gettime: (Symbol | Integer clock_id) -> Float
|
|
625
634
|
| (Symbol | Integer clock_id, :float_second | :float_millisecond | :float_microsecond unit) -> Float
|
|
@@ -906,29 +915,29 @@ module Process
|
|
|
906
915
|
#
|
|
907
916
|
# Argument `signal` specifies the signal to be sent; the argument may be:
|
|
908
917
|
#
|
|
909
|
-
# * An integer signal number: e.g.,
|
|
910
|
-
# * A signal name (string), with or without leading
|
|
911
|
-
# without a further prefixed minus sign (
|
|
918
|
+
# * An integer signal number: e.g., <code>-29</code>, `0`, `29`.
|
|
919
|
+
# * A signal name (string), with or without leading <code>'SIG'</code>, and
|
|
920
|
+
# with or without a further prefixed minus sign (<code>'-'</code>): e.g.:
|
|
912
921
|
#
|
|
913
|
-
# *
|
|
914
|
-
# *
|
|
915
|
-
# *
|
|
916
|
-
# *
|
|
922
|
+
# * <code>'SIGPOLL'</code>.
|
|
923
|
+
# * <code>'POLL'</code>,
|
|
924
|
+
# * <code>'-SIGPOLL'</code>.
|
|
925
|
+
# * <code>'-POLL'</code>.
|
|
917
926
|
#
|
|
918
|
-
# * A signal symbol, with or without leading
|
|
919
|
-
# further prefixed minus sign (
|
|
927
|
+
# * A signal symbol, with or without leading <code>'SIG'</code>, and with or
|
|
928
|
+
# without a further prefixed minus sign (<code>'-'</code>): e.g.:
|
|
920
929
|
#
|
|
921
|
-
# *
|
|
922
|
-
# *
|
|
923
|
-
# *
|
|
924
|
-
# *
|
|
930
|
+
# * <code>:SIGPOLL</code>.
|
|
931
|
+
# * <code>:POLL</code>.
|
|
932
|
+
# * <code>:'-SIGPOLL'</code>.
|
|
933
|
+
# * <code>:'-POLL'</code>.
|
|
925
934
|
#
|
|
926
935
|
# If `signal` is:
|
|
927
936
|
#
|
|
928
|
-
# * A non-negative integer, or a signal name or symbol without prefixed
|
|
929
|
-
# each process with process ID `id` is signalled.
|
|
930
|
-
# * A negative integer, or a signal name or symbol with prefixed
|
|
931
|
-
# process group with group ID `id` is signalled.
|
|
937
|
+
# * A non-negative integer, or a signal name or symbol without prefixed
|
|
938
|
+
# <code>'-'</code>, each process with process ID `id` is signalled.
|
|
939
|
+
# * A negative integer, or a signal name or symbol with prefixed
|
|
940
|
+
# <code>'-'</code>, each process group with group ID `id` is signalled.
|
|
932
941
|
#
|
|
933
942
|
# Use method Signal.list to see which signals are supported by Ruby on the
|
|
934
943
|
# underlying platform; the method returns a hash of the string names and
|
|
@@ -1064,40 +1073,46 @@ module Process
|
|
|
1064
1073
|
#
|
|
1065
1074
|
# Argument `resource` specifies the resource whose limits are to be set; the
|
|
1066
1075
|
# argument may be given as a symbol, as a string, or as a constant beginning
|
|
1067
|
-
# with
|
|
1076
|
+
# with <code>Process::RLIMIT_</code> (e.g., <code>:CORE</code>,
|
|
1077
|
+
# <code>'CORE'</code>, or <code>Process::RLIMIT_CORE</code>.
|
|
1068
1078
|
#
|
|
1069
1079
|
# The resources available and supported are system-dependent, and may include
|
|
1070
1080
|
# (here expressed as symbols):
|
|
1071
1081
|
#
|
|
1072
|
-
# *
|
|
1073
|
-
# except 4.4BSD-Lite).
|
|
1074
|
-
# *
|
|
1075
|
-
# *
|
|
1076
|
-
# *
|
|
1077
|
-
# *
|
|
1078
|
-
# *
|
|
1079
|
-
#
|
|
1080
|
-
# *
|
|
1081
|
-
# * `:NOFILE`: File descriptors (number) (SUSv3).
|
|
1082
|
-
# * `:NPROC`: Number of processes for the user (number) (4.4BSD, GNU/Linux).
|
|
1083
|
-
# * `:NPTS`: Number of pseudo terminals (number) (FreeBSD).
|
|
1084
|
-
# * `:RSS`: Resident memory size (bytes) (4.2BSD, GNU/Linux).
|
|
1085
|
-
# * `:RTPRIO`: Ceiling on the process's real-time priority (number)
|
|
1082
|
+
# * <code>:AS</code>: Total available memory (bytes) (SUSv3, NetBSD, FreeBSD,
|
|
1083
|
+
# OpenBSD except 4.4BSD-Lite).
|
|
1084
|
+
# * <code>:CORE</code>: Core size (bytes) (SUSv3).
|
|
1085
|
+
# * <code>:CPU</code>: CPU time (seconds) (SUSv3).
|
|
1086
|
+
# * <code>:DATA</code>: Data segment (bytes) (SUSv3).
|
|
1087
|
+
# * <code>:FSIZE</code>: File size (bytes) (SUSv3).
|
|
1088
|
+
# * <code>:MEMLOCK</code>: Total size for mlock(2) (bytes) (4.4BSD,
|
|
1089
|
+
# GNU/Linux).
|
|
1090
|
+
# * <code>:MSGQUEUE</code>: Allocation for POSIX message queues (bytes)
|
|
1086
1091
|
# (GNU/Linux).
|
|
1087
|
-
# *
|
|
1088
|
-
#
|
|
1089
|
-
# *
|
|
1090
|
-
# *
|
|
1092
|
+
# * <code>:NICE</code>: Ceiling on process's nice(2) value (number)
|
|
1093
|
+
# (GNU/Linux).
|
|
1094
|
+
# * <code>:NOFILE</code>: File descriptors (number) (SUSv3).
|
|
1095
|
+
# * <code>:NPROC</code>: Number of processes for the user (number) (4.4BSD,
|
|
1096
|
+
# GNU/Linux).
|
|
1097
|
+
# * <code>:NPTS</code>: Number of pseudo terminals (number) (FreeBSD).
|
|
1098
|
+
# * <code>:RSS</code>: Resident memory size (bytes) (4.2BSD, GNU/Linux).
|
|
1099
|
+
# * <code>:RTPRIO</code>: Ceiling on the process's real-time priority (number)
|
|
1100
|
+
# (GNU/Linux).
|
|
1101
|
+
# * <code>:RTTIME</code>: CPU time for real-time process (us) (GNU/Linux).
|
|
1102
|
+
# * <code>:SBSIZE</code>: All socket buffers (bytes) (NetBSD, FreeBSD).
|
|
1103
|
+
# * <code>:SIGPENDING</code>: Number of queued signals allowed (signals)
|
|
1104
|
+
# (GNU/Linux).
|
|
1105
|
+
# * <code>:STACK</code>: Stack size (bytes) (SUSv3).
|
|
1091
1106
|
#
|
|
1092
1107
|
# Arguments `cur_limit` and `max_limit` may be:
|
|
1093
1108
|
#
|
|
1094
1109
|
# * Integers (`max_limit` should not be smaller than `cur_limit`).
|
|
1095
|
-
# * Symbol
|
|
1096
|
-
#
|
|
1097
|
-
# * Symbol
|
|
1098
|
-
#
|
|
1099
|
-
# * Symbol
|
|
1100
|
-
#
|
|
1110
|
+
# * Symbol <code>:SAVED_MAX</code>, string <code>'SAVED_MAX'</code>, or
|
|
1111
|
+
# constant <code>Process::RLIM_SAVED_MAX</code>: saved maximum limit.
|
|
1112
|
+
# * Symbol <code>:SAVED_CUR</code>, string <code>'SAVED_CUR'</code>, or
|
|
1113
|
+
# constant <code>Process::RLIM_SAVED_CUR</code>: saved current limit.
|
|
1114
|
+
# * Symbol <code>:INFINITY</code>, string <code>'INFINITY'</code>, or constant
|
|
1115
|
+
# <code>Process::RLIM_INFINITY</code>: no limit on resource.
|
|
1101
1116
|
#
|
|
1102
1117
|
# This example raises the soft limit of core size to the hard limit to try to
|
|
1103
1118
|
# make core dump possible:
|
|
@@ -1164,8 +1179,8 @@ module Process
|
|
|
1164
1179
|
# - Process.wait(pid = -1, flags = 0) -> integer
|
|
1165
1180
|
# -->
|
|
1166
1181
|
# Waits for a suitable child process to exit, returns its process ID, and sets
|
|
1167
|
-
#
|
|
1168
|
-
# child it waits for depends on the value of the given `pid`:
|
|
1182
|
+
# <code>$?</code> to a Process::Status object containing information on that
|
|
1183
|
+
# process. Which child it waits for depends on the value of the given `pid`:
|
|
1169
1184
|
#
|
|
1170
1185
|
# * Positive integer: Waits for the child process whose process ID is `pid`:
|
|
1171
1186
|
#
|
|
@@ -1211,7 +1226,7 @@ module Process
|
|
|
1211
1226
|
# Process.wait(0) returned pid 225788, which is child 0 pid.
|
|
1212
1227
|
# Raised Errno::ECHILD, because child 1 process group ID differs from parent process group ID.
|
|
1213
1228
|
#
|
|
1214
|
-
# *
|
|
1229
|
+
# * <code>-1</code> (default): Waits for any child process:
|
|
1215
1230
|
#
|
|
1216
1231
|
# parent_pgpid = Process.getpgid(Process.pid)
|
|
1217
1232
|
# puts "Parent process group ID is #{parent_pgpid}."
|
|
@@ -1243,7 +1258,8 @@ module Process
|
|
|
1243
1258
|
# true
|
|
1244
1259
|
# true
|
|
1245
1260
|
#
|
|
1246
|
-
# * Less than
|
|
1261
|
+
# * Less than <code>-1</code>: Waits for any child whose process group ID is
|
|
1262
|
+
# <code>-pid</code>:
|
|
1247
1263
|
#
|
|
1248
1264
|
# parent_pgpid = Process.getpgid(Process.pid)
|
|
1249
1265
|
# puts "Parent process group ID is #{parent_pgpid}."
|
|
@@ -1329,8 +1345,8 @@ module Process
|
|
|
1329
1345
|
# - Process.wait(pid = -1, flags = 0) -> integer
|
|
1330
1346
|
# -->
|
|
1331
1347
|
# Waits for a suitable child process to exit, returns its process ID, and sets
|
|
1332
|
-
#
|
|
1333
|
-
# child it waits for depends on the value of the given `pid`:
|
|
1348
|
+
# <code>$?</code> to a Process::Status object containing information on that
|
|
1349
|
+
# process. Which child it waits for depends on the value of the given `pid`:
|
|
1334
1350
|
#
|
|
1335
1351
|
# * Positive integer: Waits for the child process whose process ID is `pid`:
|
|
1336
1352
|
#
|
|
@@ -1376,7 +1392,7 @@ module Process
|
|
|
1376
1392
|
# Process.wait(0) returned pid 225788, which is child 0 pid.
|
|
1377
1393
|
# Raised Errno::ECHILD, because child 1 process group ID differs from parent process group ID.
|
|
1378
1394
|
#
|
|
1379
|
-
# *
|
|
1395
|
+
# * <code>-1</code> (default): Waits for any child process:
|
|
1380
1396
|
#
|
|
1381
1397
|
# parent_pgpid = Process.getpgid(Process.pid)
|
|
1382
1398
|
# puts "Parent process group ID is #{parent_pgpid}."
|
|
@@ -1408,7 +1424,8 @@ module Process
|
|
|
1408
1424
|
# true
|
|
1409
1425
|
# true
|
|
1410
1426
|
#
|
|
1411
|
-
# * Less than
|
|
1427
|
+
# * Less than <code>-1</code>: Waits for any child whose process group ID is
|
|
1428
|
+
# <code>-pid</code>:
|
|
1412
1429
|
#
|
|
1413
1430
|
# parent_pgpid = Process.getpgid(Process.pid)
|
|
1414
1431
|
# puts "Parent process group ID is #{parent_pgpid}."
|
|
@@ -1483,13 +1500,14 @@ module Process
|
|
|
1483
1500
|
# running applications.
|
|
1484
1501
|
#
|
|
1485
1502
|
# This method is expected to be called at the end of the application boot. If
|
|
1486
|
-
# the application is deployed using a pre-forking model,
|
|
1487
|
-
# be called in the original process before
|
|
1503
|
+
# the application is deployed using a pre-forking model,
|
|
1504
|
+
# <code>Process.warmup</code> should be called in the original process before
|
|
1505
|
+
# the first fork.
|
|
1488
1506
|
#
|
|
1489
1507
|
# The actual optimizations performed are entirely implementation specific and
|
|
1490
1508
|
# may change in the future without notice.
|
|
1491
1509
|
#
|
|
1492
|
-
# On CRuby,
|
|
1510
|
+
# On CRuby, <code>Process.warmup</code>:
|
|
1493
1511
|
#
|
|
1494
1512
|
# * Performs a major GC.
|
|
1495
1513
|
# * Compacts the heap.
|
|
@@ -1832,9 +1850,9 @@ end
|
|
|
1832
1850
|
# <!-- rdoc-file=process.c -->
|
|
1833
1851
|
# A Process::Status contains information about a system process.
|
|
1834
1852
|
#
|
|
1835
|
-
# Thread-local variable
|
|
1836
|
-
# Process::Status object that represents a system process (either
|
|
1837
|
-
# terminated):
|
|
1853
|
+
# Thread-local variable <code>$?</code> is initially `nil`. Some methods assign
|
|
1854
|
+
# to it a Process::Status object that represents a system process (either
|
|
1855
|
+
# running or terminated):
|
|
1838
1856
|
#
|
|
1839
1857
|
# `ruby -e "exit 99"`
|
|
1840
1858
|
# stat = $? # => #<Process::Status: pid 1262862 exit 99>
|
|
@@ -1912,8 +1930,8 @@ class Process::Status < Object
|
|
|
1912
1930
|
# rdoc-file=process.c
|
|
1913
1931
|
# - exited? -> true or false
|
|
1914
1932
|
# -->
|
|
1915
|
-
# Returns `true` if the process exited normally (for example using an
|
|
1916
|
-
# call or finishing the program), `false` if not.
|
|
1933
|
+
# Returns `true` if the process exited normally (for example using an
|
|
1934
|
+
# <code>exit()</code> call or finishing the program), `false` if not.
|
|
1917
1935
|
#
|
|
1918
1936
|
def exited?: () -> bool
|
|
1919
1937
|
|
|
@@ -2108,8 +2126,8 @@ module Process::Sys
|
|
|
2108
2126
|
# - Process::Sys.setregid(rid, eid) -> nil
|
|
2109
2127
|
# -->
|
|
2110
2128
|
# Sets the (group) real and/or effective group IDs of the current process to
|
|
2111
|
-
# *rid* and *eid*, respectively. A value of
|
|
2112
|
-
# ID unchanged. Not available on all platforms.
|
|
2129
|
+
# *rid* and *eid*, respectively. A value of <code>-1</code> for either means to
|
|
2130
|
+
# leave that ID unchanged. Not available on all platforms.
|
|
2113
2131
|
#
|
|
2114
2132
|
def self.setregid: (Integer rid, Integer eid) -> nil
|
|
2115
2133
|
|
|
@@ -2118,8 +2136,8 @@ module Process::Sys
|
|
|
2118
2136
|
# - Process::Sys.setresgid(rid, eid, sid) -> nil
|
|
2119
2137
|
# -->
|
|
2120
2138
|
# Sets the (group) real, effective, and saved user IDs of the current process to
|
|
2121
|
-
# *rid*, *eid*, and *sid* respectively. A value of
|
|
2122
|
-
# leave that ID unchanged. Not available on all platforms.
|
|
2139
|
+
# *rid*, *eid*, and *sid* respectively. A value of <code>-1</code> for any value
|
|
2140
|
+
# means to leave that ID unchanged. Not available on all platforms.
|
|
2123
2141
|
#
|
|
2124
2142
|
def self.setresgid: (Integer rid, Integer eid, Integer sid) -> nil
|
|
2125
2143
|
|
|
@@ -2128,8 +2146,8 @@ module Process::Sys
|
|
|
2128
2146
|
# - Process::Sys.setresuid(rid, eid, sid) -> nil
|
|
2129
2147
|
# -->
|
|
2130
2148
|
# Sets the (user) real, effective, and saved user IDs of the current process to
|
|
2131
|
-
# *rid*, *eid*, and *sid* respectively. A value of
|
|
2132
|
-
# leave that ID unchanged. Not available on all platforms.
|
|
2149
|
+
# *rid*, *eid*, and *sid* respectively. A value of <code>-1</code> for any value
|
|
2150
|
+
# means to leave that ID unchanged. Not available on all platforms.
|
|
2133
2151
|
#
|
|
2134
2152
|
def self.setresuid: (Integer rid, Integer eid, Integer sid) -> nil
|
|
2135
2153
|
|
|
@@ -2138,8 +2156,8 @@ module Process::Sys
|
|
|
2138
2156
|
# - Process::Sys.setreuid(rid, eid) -> nil
|
|
2139
2157
|
# -->
|
|
2140
2158
|
# Sets the (user) real and/or effective user IDs of the current process to *rid*
|
|
2141
|
-
# and *eid*, respectively. A value of
|
|
2142
|
-
# unchanged. Not available on all platforms.
|
|
2159
|
+
# and *eid*, respectively. A value of <code>-1</code> for either means to leave
|
|
2160
|
+
# that ID unchanged. Not available on all platforms.
|
|
2143
2161
|
#
|
|
2144
2162
|
def self.setreuid: (Integer rid, Integer eid) -> nil
|
|
2145
2163
|
|