rbs-relaxed 3.9.0.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 +7 -0
- data/.github/dependabot.yml +22 -0
- data/.github/workflows/comments.yml +35 -0
- data/.github/workflows/dependabot.yml +30 -0
- data/.github/workflows/ruby.yml +82 -0
- data/.github/workflows/typecheck.yml +38 -0
- data/.github/workflows/windows.yml +43 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +68 -0
- data/BSDL +22 -0
- data/CHANGELOG.md +1868 -0
- data/COPYING +56 -0
- data/README.md +203 -0
- data/Rakefile +417 -0
- data/Steepfile +44 -0
- data/config.yml +313 -0
- data/core/array.rbs +4062 -0
- data/core/basic_object.rbs +375 -0
- data/core/binding.rbs +150 -0
- data/core/builtin.rbs +277 -0
- data/core/class.rbs +220 -0
- data/core/comparable.rbs +171 -0
- data/core/complex.rbs +786 -0
- data/core/constants.rbs +96 -0
- data/core/data.rbs +415 -0
- data/core/dir.rbs +981 -0
- data/core/encoding.rbs +1371 -0
- data/core/enumerable.rbs +2405 -0
- data/core/enumerator/product.rbs +92 -0
- data/core/enumerator.rbs +630 -0
- data/core/env.rbs +6 -0
- data/core/errno.rbs +673 -0
- data/core/errors.rbs +760 -0
- data/core/exception.rbs +485 -0
- data/core/false_class.rbs +82 -0
- data/core/fiber.rbs +550 -0
- data/core/fiber_error.rbs +11 -0
- data/core/file.rbs +2936 -0
- data/core/file_test.rbs +331 -0
- data/core/float.rbs +1151 -0
- data/core/gc.rbs +644 -0
- data/core/global_variables.rbs +184 -0
- data/core/hash.rbs +1861 -0
- data/core/integer.rbs +1413 -0
- data/core/io/buffer.rbs +984 -0
- data/core/io/wait.rbs +70 -0
- data/core/io.rbs +3406 -0
- data/core/kernel.rbs +3096 -0
- data/core/marshal.rbs +207 -0
- data/core/match_data.rbs +635 -0
- data/core/math.rbs +729 -0
- data/core/method.rbs +386 -0
- data/core/module.rbs +1704 -0
- data/core/nil_class.rbs +209 -0
- data/core/numeric.rbs +818 -0
- data/core/object.rbs +110 -0
- data/core/object_space/weak_key_map.rbs +166 -0
- data/core/object_space.rbs +190 -0
- data/core/proc.rbs +868 -0
- data/core/process.rbs +2296 -0
- data/core/ractor.rbs +1068 -0
- data/core/random.rbs +237 -0
- data/core/range.rbs +1107 -0
- data/core/rational.rbs +531 -0
- data/core/rb_config.rbs +88 -0
- data/core/rbs/unnamed/argf.rbs +1229 -0
- data/core/rbs/unnamed/env_class.rbs +1209 -0
- data/core/rbs/unnamed/random.rbs +293 -0
- data/core/refinement.rbs +59 -0
- data/core/regexp.rbs +1930 -0
- data/core/ruby_vm.rbs +765 -0
- data/core/rubygems/basic_specification.rbs +6 -0
- data/core/rubygems/config_file.rbs +38 -0
- data/core/rubygems/dependency_installer.rbs +6 -0
- data/core/rubygems/errors.rbs +176 -0
- data/core/rubygems/installer.rbs +15 -0
- data/core/rubygems/path_support.rbs +6 -0
- data/core/rubygems/platform.rbs +7 -0
- data/core/rubygems/request_set.rbs +49 -0
- data/core/rubygems/requirement.rbs +148 -0
- data/core/rubygems/rubygems.rbs +1171 -0
- data/core/rubygems/source_list.rbs +15 -0
- data/core/rubygems/specification.rbs +23 -0
- data/core/rubygems/stream_ui.rbs +5 -0
- data/core/rubygems/uninstaller.rbs +10 -0
- data/core/rubygems/version.rbs +294 -0
- data/core/set.rbs +621 -0
- data/core/signal.rbs +100 -0
- data/core/string.rbs +3583 -0
- data/core/struct.rbs +667 -0
- data/core/symbol.rbs +475 -0
- data/core/thread.rbs +1765 -0
- data/core/thread_group.rbs +79 -0
- data/core/time.rbs +1762 -0
- data/core/trace_point.rbs +477 -0
- data/core/true_class.rbs +98 -0
- data/core/unbound_method.rbs +329 -0
- data/core/warning.rbs +87 -0
- data/docs/CONTRIBUTING.md +106 -0
- data/docs/architecture.md +110 -0
- data/docs/collection.md +192 -0
- data/docs/data_and_struct.md +86 -0
- data/docs/gem.md +57 -0
- data/docs/rbs_by_example.md +309 -0
- data/docs/repo.md +125 -0
- data/docs/sigs.md +167 -0
- data/docs/stdlib.md +147 -0
- data/docs/syntax.md +910 -0
- data/docs/tools.md +17 -0
- data/exe/rbs +7 -0
- data/ext/rbs_extension/extconf.rb +15 -0
- data/ext/rbs_extension/lexer.c +2728 -0
- data/ext/rbs_extension/lexer.h +179 -0
- data/ext/rbs_extension/lexer.re +147 -0
- data/ext/rbs_extension/lexstate.c +175 -0
- data/ext/rbs_extension/location.c +325 -0
- data/ext/rbs_extension/location.h +85 -0
- data/ext/rbs_extension/main.c +33 -0
- data/ext/rbs_extension/parser.c +2973 -0
- data/ext/rbs_extension/parser.h +18 -0
- data/ext/rbs_extension/parserstate.c +397 -0
- data/ext/rbs_extension/parserstate.h +163 -0
- data/ext/rbs_extension/rbs_extension.h +31 -0
- data/ext/rbs_extension/unescape.c +32 -0
- data/goodcheck.yml +91 -0
- data/include/rbs/constants.h +82 -0
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/ancestor_graph.rb +92 -0
- data/lib/rbs/annotate/annotations.rb +199 -0
- data/lib/rbs/annotate/formatter.rb +92 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +400 -0
- data/lib/rbs/annotate/rdoc_source.rb +131 -0
- data/lib/rbs/annotate.rb +8 -0
- data/lib/rbs/ast/annotation.rb +29 -0
- data/lib/rbs/ast/comment.rb +29 -0
- data/lib/rbs/ast/declarations.rb +467 -0
- data/lib/rbs/ast/directives.rb +49 -0
- data/lib/rbs/ast/members.rb +451 -0
- data/lib/rbs/ast/type_param.rb +225 -0
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/buffer.rb +67 -0
- data/lib/rbs/builtin_names.rb +58 -0
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +83 -0
- data/lib/rbs/cli/validate.rb +357 -0
- data/lib/rbs/cli.rb +1223 -0
- data/lib/rbs/collection/cleaner.rb +38 -0
- data/lib/rbs/collection/config/lockfile.rb +92 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +218 -0
- data/lib/rbs/collection/config.rb +81 -0
- data/lib/rbs/collection/installer.rb +32 -0
- data/lib/rbs/collection/sources/base.rb +14 -0
- data/lib/rbs/collection/sources/git.rb +258 -0
- data/lib/rbs/collection/sources/local.rb +81 -0
- data/lib/rbs/collection/sources/rubygems.rb +48 -0
- data/lib/rbs/collection/sources/stdlib.rb +50 -0
- data/lib/rbs/collection/sources.rb +38 -0
- data/lib/rbs/collection.rb +16 -0
- data/lib/rbs/constant.rb +28 -0
- data/lib/rbs/definition.rb +401 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +620 -0
- data/lib/rbs/definition_builder/method_builder.rb +254 -0
- data/lib/rbs/definition_builder.rb +845 -0
- data/lib/rbs/diff.rb +125 -0
- data/lib/rbs/environment/use_map.rb +77 -0
- data/lib/rbs/environment.rb +829 -0
- data/lib/rbs/environment_loader.rb +173 -0
- data/lib/rbs/environment_walker.rb +155 -0
- data/lib/rbs/errors.rb +645 -0
- data/lib/rbs/factory.rb +18 -0
- data/lib/rbs/file_finder.rb +28 -0
- data/lib/rbs/location_aux.rb +138 -0
- data/lib/rbs/locator.rb +243 -0
- data/lib/rbs/method_type.rb +143 -0
- data/lib/rbs/namespace.rb +125 -0
- data/lib/rbs/parser/lex_result.rb +15 -0
- data/lib/rbs/parser/token.rb +23 -0
- data/lib/rbs/parser_aux.rb +114 -0
- data/lib/rbs/prototype/helpers.rb +140 -0
- data/lib/rbs/prototype/node_usage.rb +99 -0
- data/lib/rbs/prototype/rb.rb +840 -0
- data/lib/rbs/prototype/rbi.rb +641 -0
- data/lib/rbs/prototype/runtime/helpers.rb +59 -0
- data/lib/rbs/prototype/runtime/reflection.rb +19 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
- data/lib/rbs/prototype/runtime.rb +667 -0
- data/lib/rbs/repository.rb +127 -0
- data/lib/rbs/resolver/constant_resolver.rb +219 -0
- data/lib/rbs/resolver/type_name_resolver.rb +91 -0
- data/lib/rbs/sorter.rb +198 -0
- data/lib/rbs/substitution.rb +83 -0
- data/lib/rbs/subtractor.rb +201 -0
- data/lib/rbs/test/errors.rb +80 -0
- data/lib/rbs/test/guaranteed.rb +30 -0
- data/lib/rbs/test/hook.rb +212 -0
- data/lib/rbs/test/observer.rb +19 -0
- data/lib/rbs/test/setup.rb +84 -0
- data/lib/rbs/test/setup_helper.rb +50 -0
- data/lib/rbs/test/tester.rb +167 -0
- data/lib/rbs/test/type_check.rb +435 -0
- data/lib/rbs/test.rb +112 -0
- data/lib/rbs/type_alias_dependency.rb +100 -0
- data/lib/rbs/type_alias_regularity.rb +126 -0
- data/lib/rbs/type_name.rb +109 -0
- data/lib/rbs/types.rb +1596 -0
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +138 -0
- data/lib/rbs/unit_test/type_assertions.rb +347 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/validator.rb +186 -0
- data/lib/rbs/variance_calculator.rb +189 -0
- data/lib/rbs/vendorer.rb +71 -0
- data/lib/rbs/version.rb +5 -0
- data/lib/rbs/writer.rb +424 -0
- data/lib/rbs.rb +94 -0
- data/lib/rdoc/discover.rb +20 -0
- data/lib/rdoc_plugin/parser.rb +163 -0
- data/rbs-relaxed.gemspec +48 -0
- data/schema/annotation.json +14 -0
- data/schema/comment.json +26 -0
- data/schema/decls.json +326 -0
- data/schema/function.json +87 -0
- data/schema/location.json +56 -0
- data/schema/members.json +266 -0
- data/schema/methodType.json +50 -0
- data/schema/typeParam.json +36 -0
- data/schema/types.json +317 -0
- data/sig/ancestor_builder.rbs +163 -0
- data/sig/ancestor_graph.rbs +60 -0
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/annotation.rbs +27 -0
- data/sig/buffer.rbs +32 -0
- data/sig/builtin_names.rbs +44 -0
- data/sig/cli/colored_io.rbs +15 -0
- data/sig/cli/diff.rbs +21 -0
- data/sig/cli/validate.rbs +43 -0
- data/sig/cli.rbs +87 -0
- data/sig/collection/cleaner.rbs +13 -0
- data/sig/collection/config/lockfile.rbs +74 -0
- data/sig/collection/config/lockfile_generator.rbs +66 -0
- data/sig/collection/config.rbs +46 -0
- data/sig/collection/installer.rbs +17 -0
- data/sig/collection/sources.rbs +214 -0
- data/sig/collection.rbs +4 -0
- data/sig/comment.rbs +26 -0
- data/sig/constant.rbs +21 -0
- data/sig/declarations.rbs +267 -0
- data/sig/definition.rbs +173 -0
- data/sig/definition_builder.rbs +165 -0
- data/sig/diff.rbs +28 -0
- data/sig/directives.rbs +77 -0
- data/sig/environment.rbs +279 -0
- data/sig/environment_loader.rbs +111 -0
- data/sig/environment_walker.rbs +65 -0
- data/sig/errors.rbs +405 -0
- data/sig/factory.rbs +5 -0
- data/sig/file_finder.rbs +28 -0
- data/sig/location.rbs +110 -0
- data/sig/locator.rbs +58 -0
- data/sig/manifest.yaml +7 -0
- data/sig/members.rbs +258 -0
- data/sig/method_builder.rbs +84 -0
- data/sig/method_types.rbs +58 -0
- data/sig/namespace.rbs +146 -0
- data/sig/parser.rbs +100 -0
- data/sig/prototype/helpers.rbs +27 -0
- data/sig/prototype/node_usage.rbs +20 -0
- data/sig/prototype/rb.rbs +96 -0
- data/sig/prototype/rbi.rbs +75 -0
- data/sig/prototype/runtime.rbs +182 -0
- data/sig/rbs.rbs +21 -0
- data/sig/rdoc/rbs.rbs +67 -0
- data/sig/repository.rbs +85 -0
- data/sig/resolver/constant_resolver.rbs +92 -0
- data/sig/resolver/context.rbs +34 -0
- data/sig/resolver/type_name_resolver.rbs +35 -0
- data/sig/shims/bundler.rbs +38 -0
- data/sig/shims/enumerable.rbs +5 -0
- data/sig/shims/rubygems.rbs +19 -0
- data/sig/sorter.rbs +41 -0
- data/sig/substitution.rbs +48 -0
- data/sig/subtractor.rbs +37 -0
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/type_alias_dependency.rbs +53 -0
- data/sig/type_alias_regularity.rbs +98 -0
- data/sig/type_param.rbs +110 -0
- data/sig/typename.rbs +79 -0
- data/sig/types.rbs +579 -0
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +30 -0
- data/sig/unit_test/type_assertions.rbs +196 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/sig/use_map.rbs +35 -0
- data/sig/util.rbs +9 -0
- data/sig/validator.rbs +63 -0
- data/sig/variance_calculator.rbs +87 -0
- data/sig/vendorer.rbs +51 -0
- data/sig/version.rbs +3 -0
- data/sig/visitor.rbs +47 -0
- data/sig/writer.rbs +127 -0
- data/src/constants.c +153 -0
- data/src/ruby_objs.c +795 -0
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/abbrev/0/abbrev.rbs +66 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +355 -0
- data/stdlib/benchmark/0/benchmark.rbs +452 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +1629 -0
- data/stdlib/bigdecimal-math/0/big_math.rbs +119 -0
- data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
- data/stdlib/cgi/0/core.rbs +1285 -0
- data/stdlib/cgi/0/manifest.yaml +3 -0
- data/stdlib/coverage/0/coverage.rbs +263 -0
- data/stdlib/csv/0/csv.rbs +3776 -0
- data/stdlib/csv/0/manifest.yaml +3 -0
- data/stdlib/date/0/date.rbs +1585 -0
- data/stdlib/date/0/date_time.rbs +616 -0
- data/stdlib/date/0/time.rbs +26 -0
- data/stdlib/dbm/0/dbm.rbs +421 -0
- data/stdlib/delegate/0/delegator.rbs +184 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +96 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +343 -0
- data/stdlib/digest/0/digest.rbs +577 -0
- data/stdlib/erb/0/erb.rbs +532 -0
- data/stdlib/etc/0/etc.rbs +865 -0
- data/stdlib/fileutils/0/fileutils.rbs +1734 -0
- data/stdlib/find/0/find.rbs +49 -0
- data/stdlib/forwardable/0/forwardable.rbs +268 -0
- data/stdlib/io-console/0/io-console.rbs +414 -0
- data/stdlib/ipaddr/0/ipaddr.rbs +428 -0
- data/stdlib/json/0/json.rbs +1916 -0
- data/stdlib/kconv/0/kconv.rbs +166 -0
- data/stdlib/logger/0/formatter.rbs +45 -0
- data/stdlib/logger/0/log_device.rbs +100 -0
- data/stdlib/logger/0/logger.rbs +796 -0
- data/stdlib/logger/0/manifest.yaml +2 -0
- data/stdlib/logger/0/period.rbs +17 -0
- data/stdlib/logger/0/severity.rbs +34 -0
- data/stdlib/minitest/0/kernel.rbs +42 -0
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
- data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
- data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
- data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
- data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
- data/stdlib/minitest/0/minitest/guard.rbs +64 -0
- data/stdlib/minitest/0/minitest/mock.rbs +64 -0
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
- data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
- data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
- data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
- data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
- data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/result.rbs +28 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
- data/stdlib/minitest/0/minitest/skip.rbs +6 -0
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
- data/stdlib/minitest/0/minitest/spec.rbs +11 -0
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
- data/stdlib/minitest/0/minitest/test.rbs +69 -0
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
- data/stdlib/minitest/0/minitest/unit.rbs +4 -0
- data/stdlib/minitest/0/minitest.rbs +115 -0
- data/stdlib/monitor/0/monitor.rbs +363 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
- data/stdlib/net-http/0/manifest.yaml +3 -0
- data/stdlib/net-http/0/net-http.rbs +5552 -0
- data/stdlib/net-protocol/0/manifest.yaml +2 -0
- data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
- data/stdlib/net-smtp/0/manifest.yaml +2 -0
- data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
- data/stdlib/nkf/0/nkf.rbs +402 -0
- data/stdlib/objspace/0/objspace.rbs +487 -0
- data/stdlib/observable/0/observable.rbs +217 -0
- data/stdlib/open-uri/0/manifest.yaml +4 -0
- data/stdlib/open-uri/0/open-uri.rbs +393 -0
- data/stdlib/open3/0/open3.rbs +147 -0
- data/stdlib/openssl/0/manifest.yaml +3 -0
- data/stdlib/openssl/0/openssl.rbs +12113 -0
- data/stdlib/optparse/0/optparse.rbs +1725 -0
- data/stdlib/pathname/0/pathname.rbs +1406 -0
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +300 -0
- data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
- data/stdlib/pstore/0/pstore.rbs +603 -0
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/psych/0/dbm.rbs +237 -0
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +402 -0
- data/stdlib/psych/0/store.rbs +59 -0
- data/stdlib/pty/0/pty.rbs +237 -0
- data/stdlib/rdoc/0/code_object.rbs +51 -0
- data/stdlib/rdoc/0/comment.rbs +59 -0
- data/stdlib/rdoc/0/context.rbs +153 -0
- data/stdlib/rdoc/0/markup.rbs +117 -0
- data/stdlib/rdoc/0/parser.rbs +56 -0
- data/stdlib/rdoc/0/rdoc.rbs +391 -0
- data/stdlib/rdoc/0/ri.rbs +17 -0
- data/stdlib/rdoc/0/store.rbs +48 -0
- data/stdlib/rdoc/0/top_level.rbs +97 -0
- data/stdlib/resolv/0/manifest.yaml +3 -0
- data/stdlib/resolv/0/resolv.rbs +1830 -0
- data/stdlib/ripper/0/ripper.rbs +1648 -0
- data/stdlib/securerandom/0/securerandom.rbs +62 -0
- data/stdlib/shellwords/0/shellwords.rbs +229 -0
- data/stdlib/singleton/0/singleton.rbs +131 -0
- data/stdlib/socket/0/addrinfo.rbs +666 -0
- data/stdlib/socket/0/basic_socket.rbs +590 -0
- data/stdlib/socket/0/constants.rbs +2295 -0
- data/stdlib/socket/0/ip_socket.rbs +92 -0
- data/stdlib/socket/0/socket.rbs +4157 -0
- data/stdlib/socket/0/socket_error.rbs +5 -0
- data/stdlib/socket/0/tcp_server.rbs +192 -0
- data/stdlib/socket/0/tcp_socket.rbs +79 -0
- data/stdlib/socket/0/udp_socket.rbs +133 -0
- data/stdlib/socket/0/unix_server.rbs +169 -0
- data/stdlib/socket/0/unix_socket.rbs +172 -0
- data/stdlib/stringio/0/stringio.rbs +567 -0
- data/stdlib/strscan/0/string_scanner.rbs +1627 -0
- data/stdlib/tempfile/0/tempfile.rbs +479 -0
- data/stdlib/time/0/time.rbs +432 -0
- data/stdlib/timeout/0/timeout.rbs +81 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
- data/stdlib/tsort/0/cyclic.rbs +5 -0
- data/stdlib/tsort/0/interfaces.rbs +20 -0
- data/stdlib/tsort/0/tsort.rbs +409 -0
- data/stdlib/uri/0/common.rbs +582 -0
- data/stdlib/uri/0/file.rbs +118 -0
- data/stdlib/uri/0/ftp.rbs +13 -0
- data/stdlib/uri/0/generic.rbs +1108 -0
- data/stdlib/uri/0/http.rbs +104 -0
- data/stdlib/uri/0/https.rbs +14 -0
- data/stdlib/uri/0/ldap.rbs +230 -0
- data/stdlib/uri/0/ldaps.rbs +14 -0
- data/stdlib/uri/0/mailto.rbs +92 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
- data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
- data/stdlib/uri/0/ws.rbs +13 -0
- data/stdlib/uri/0/wss.rbs +9 -0
- data/stdlib/yaml/0/manifest.yaml +2 -0
- data/stdlib/yaml/0/yaml.rbs +1 -0
- data/stdlib/zlib/0/buf_error.rbs +10 -0
- data/stdlib/zlib/0/data_error.rbs +10 -0
- data/stdlib/zlib/0/deflate.rbs +210 -0
- data/stdlib/zlib/0/error.rbs +20 -0
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
- data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
- data/stdlib/zlib/0/gzip_file.rbs +156 -0
- data/stdlib/zlib/0/gzip_reader.rbs +293 -0
- data/stdlib/zlib/0/gzip_writer.rbs +166 -0
- data/stdlib/zlib/0/inflate.rbs +180 -0
- data/stdlib/zlib/0/mem_error.rbs +10 -0
- data/stdlib/zlib/0/need_dict.rbs +13 -0
- data/stdlib/zlib/0/stream_end.rbs +11 -0
- data/stdlib/zlib/0/stream_error.rbs +11 -0
- data/stdlib/zlib/0/version_error.rbs +11 -0
- data/stdlib/zlib/0/zlib.rbs +449 -0
- data/stdlib/zlib/0/zstream.rbs +200 -0
- metadata +532 -0
data/core/process.rbs
ADDED
@@ -0,0 +1,2296 @@
|
|
1
|
+
# <!-- rdoc-file=process.c -->
|
2
|
+
# Module `Process` represents a process in the underlying operating system. Its
|
3
|
+
# methods support management of the current process and its child processes.
|
4
|
+
#
|
5
|
+
# ## Process Creation
|
6
|
+
#
|
7
|
+
# Each of the following methods executes a given command in a new process or
|
8
|
+
# subshell, or multiple commands in new processes and/or subshells. The choice
|
9
|
+
# of process or subshell depends on the form of the command; see [Argument
|
10
|
+
# command_line or exe_path](rdoc-ref:Process@Argument+command_line+or+exe_path).
|
11
|
+
#
|
12
|
+
# * Process.spawn, Kernel#spawn: Executes the command; returns the new pid
|
13
|
+
# without waiting for completion.
|
14
|
+
# * Process.exec: Replaces the current process by executing the command.
|
15
|
+
#
|
16
|
+
# In addition:
|
17
|
+
#
|
18
|
+
# * Method Kernel#system executes a given command-line (string) in a subshell;
|
19
|
+
# returns `true`, `false`, or `nil`.
|
20
|
+
# * Method Kernel#` executes a given command-line (string) in a subshell;
|
21
|
+
# returns its $stdout string.
|
22
|
+
# * Module Open3 supports creating child processes with access to their
|
23
|
+
# $stdin, $stdout, and $stderr streams.
|
24
|
+
#
|
25
|
+
# ### Execution Environment
|
26
|
+
#
|
27
|
+
# Optional leading argument `env` is a hash of name/value pairs, where each name
|
28
|
+
# is a string and each value is a string or `nil`; each name/value pair is added
|
29
|
+
# to ENV in the new process.
|
30
|
+
#
|
31
|
+
# Process.spawn( 'ruby -e "p ENV[\"Foo\"]"')
|
32
|
+
# Process.spawn({'Foo' => '0'}, 'ruby -e "p ENV[\"Foo\"]"')
|
33
|
+
#
|
34
|
+
# Output:
|
35
|
+
#
|
36
|
+
# "0"
|
37
|
+
#
|
38
|
+
# The effect is usually similar to that of calling ENV#update with argument
|
39
|
+
# `env`, where each named environment variable is created or updated (if the
|
40
|
+
# value is non-`nil`), or deleted (if the value is `nil`).
|
41
|
+
#
|
42
|
+
# However, some modifications to the calling process may remain if the new
|
43
|
+
# process fails. For example, hard resource limits are not restored.
|
44
|
+
#
|
45
|
+
# ### Argument `command_line` or `exe_path`
|
46
|
+
#
|
47
|
+
# The required string argument is one of the following:
|
48
|
+
#
|
49
|
+
# * `command_line` if it begins with a shell reserved word or special
|
50
|
+
# built-in, or if it contains one or more meta characters.
|
51
|
+
# * `exe_path` otherwise.
|
52
|
+
#
|
53
|
+
# #### Argument `command_line`
|
54
|
+
#
|
55
|
+
# String argument `command_line` is a command line to be passed to a shell; it
|
56
|
+
# must begin with a shell reserved word, begin with a special built-in, or
|
57
|
+
# contain meta characters:
|
58
|
+
#
|
59
|
+
# system('if true; then echo "Foo"; fi') # => true # Shell reserved word.
|
60
|
+
# system('exit') # => true # Built-in.
|
61
|
+
# system('date > /tmp/date.tmp') # => true # Contains meta character.
|
62
|
+
# system('date > /nop/date.tmp') # => false
|
63
|
+
# system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
|
64
|
+
#
|
65
|
+
# The command line may also contain arguments and options for the command:
|
66
|
+
#
|
67
|
+
# system('echo "Foo"') # => true
|
68
|
+
#
|
69
|
+
# Output:
|
70
|
+
#
|
71
|
+
# Foo
|
72
|
+
#
|
73
|
+
# See [Execution Shell](rdoc-ref:Process@Execution+Shell) for details about the
|
74
|
+
# shell.
|
75
|
+
#
|
76
|
+
# #### Argument `exe_path`
|
77
|
+
#
|
78
|
+
# Argument `exe_path` is one of the following:
|
79
|
+
#
|
80
|
+
# * The string path to an executable file to be called:
|
81
|
+
#
|
82
|
+
# Example:
|
83
|
+
#
|
84
|
+
# system('/usr/bin/date') # => true # Path to date on Unix-style system.
|
85
|
+
# system('foo') # => nil # Command execlution failed.
|
86
|
+
#
|
87
|
+
# Output:
|
88
|
+
#
|
89
|
+
# Thu Aug 31 10:06:48 AM CDT 2023
|
90
|
+
#
|
91
|
+
# A path or command name containing spaces without arguments cannot be
|
92
|
+
# distinguished from `command_line` above, so you must quote or escape the
|
93
|
+
# entire command name using a shell in platform dependent manner, or use the
|
94
|
+
# array form below.
|
95
|
+
#
|
96
|
+
# If `exe_path` does not contain any path separator, an executable file is
|
97
|
+
# searched from directories specified with the `PATH` environment variable.
|
98
|
+
# What the word "executable" means here is depending on platforms.
|
99
|
+
#
|
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 `/bin/sh`
|
102
|
+
# on a Unix-like system, like system(3) does.
|
103
|
+
#
|
104
|
+
# File.write('shell_command', 'echo $SHELL', perm: 0o755)
|
105
|
+
# system('./shell_command') # prints "/bin/sh" or something.
|
106
|
+
#
|
107
|
+
# * A 2-element array containing the path to an executable and the string to
|
108
|
+
# be used as the name of the executing process:
|
109
|
+
#
|
110
|
+
# Example:
|
111
|
+
#
|
112
|
+
# pid = spawn(['sleep', 'Hello!'], '1') # 2-element array.
|
113
|
+
# p `ps -p #{pid} -o command=`
|
114
|
+
#
|
115
|
+
# Output:
|
116
|
+
#
|
117
|
+
# "Hello! 1\n"
|
118
|
+
#
|
119
|
+
# ### Arguments `args`
|
120
|
+
#
|
121
|
+
# If `command_line` does not contain shell meta characters except for spaces and
|
122
|
+
# tabs, or `exe_path` is given, Ruby invokes the executable directly. This form
|
123
|
+
# does not use the shell:
|
124
|
+
#
|
125
|
+
# spawn("doesnt_exist") # Raises Errno::ENOENT
|
126
|
+
# spawn("doesnt_exist", "\n") # Raises Errno::ENOENT
|
127
|
+
#
|
128
|
+
# spawn("doesnt_exist\n") # => false
|
129
|
+
# # sh: 1: doesnot_exist: not found
|
130
|
+
#
|
131
|
+
# The error message is from a shell and would vary depending on your system.
|
132
|
+
#
|
133
|
+
# If one or more `args` is given after `exe_path`, each is an argument or option
|
134
|
+
# to be passed to the executable:
|
135
|
+
#
|
136
|
+
# Example:
|
137
|
+
#
|
138
|
+
# system('echo', '<', 'C*', '|', '$SHELL', '>') # => true
|
139
|
+
#
|
140
|
+
# Output:
|
141
|
+
#
|
142
|
+
# < C* | $SHELL >
|
143
|
+
#
|
144
|
+
# However, there are exceptions on Windows. See [Execution Shell on
|
145
|
+
# Windows](rdoc-ref:Process@Execution+Shell+on+Windows).
|
146
|
+
#
|
147
|
+
# If you want to invoke a path containing spaces with no arguments without
|
148
|
+
# shell, you will need to use a 2-element array `exe_path`.
|
149
|
+
#
|
150
|
+
# Example:
|
151
|
+
#
|
152
|
+
# path = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
153
|
+
# spawn(path) # Raises Errno::ENOENT; No such file or directory - /Applications/Google
|
154
|
+
# spawn([path] * 2)
|
155
|
+
#
|
156
|
+
# ### Execution Options
|
157
|
+
#
|
158
|
+
# Optional trailing argument `options` is a hash of execution options.
|
159
|
+
#
|
160
|
+
# #### Working Directory (`:chdir`)
|
161
|
+
#
|
162
|
+
# By default, the working directory for the new process is the same as that of
|
163
|
+
# the current process:
|
164
|
+
#
|
165
|
+
# Dir.chdir('/var')
|
166
|
+
# Process.spawn('ruby -e "puts Dir.pwd"')
|
167
|
+
#
|
168
|
+
# Output:
|
169
|
+
#
|
170
|
+
# /var
|
171
|
+
#
|
172
|
+
# Use option `:chdir` to set the working directory for the new process:
|
173
|
+
#
|
174
|
+
# Process.spawn('ruby -e "puts Dir.pwd"', {chdir: '/tmp'})
|
175
|
+
#
|
176
|
+
# Output:
|
177
|
+
#
|
178
|
+
# /tmp
|
179
|
+
#
|
180
|
+
# The working directory of the current process is not changed:
|
181
|
+
#
|
182
|
+
# Dir.pwd # => "/var"
|
183
|
+
#
|
184
|
+
# #### File Redirection (File Descriptor)
|
185
|
+
#
|
186
|
+
# Use execution options for file redirection in the new process.
|
187
|
+
#
|
188
|
+
# The key for such an option may be an integer file descriptor (fd), specifying
|
189
|
+
# a source, or an array of fds, specifying multiple sources.
|
190
|
+
#
|
191
|
+
# An integer source fd may be specified as:
|
192
|
+
#
|
193
|
+
# * *n*: Specifies file descriptor *n*.
|
194
|
+
#
|
195
|
+
# There are these shorthand symbols for fds:
|
196
|
+
#
|
197
|
+
# * `:in`: Specifies file descriptor 0 (STDIN).
|
198
|
+
# * `:out`: Specifies file descriptor 1 (STDOUT).
|
199
|
+
# * `:err`: Specifies file descriptor 2 (STDERR).
|
200
|
+
#
|
201
|
+
# The value given with a source is one of:
|
202
|
+
#
|
203
|
+
# * *n*: Redirects to fd *n* in the parent process.
|
204
|
+
# * `filepath`: Redirects from or to the file at `filepath` via
|
205
|
+
# `open(filepath, mode, 0644)`, where `mode` is `'r'` for source `:in`, or
|
206
|
+
# `'w'` for source `:out` or `:err`.
|
207
|
+
# * `[filepath]`: Redirects from the file at `filepath` via `open(filepath,
|
208
|
+
# 'r', 0644)`.
|
209
|
+
# * `[filepath, mode]`: Redirects from or to the file at `filepath` via
|
210
|
+
# `open(filepath, mode, 0644)`.
|
211
|
+
# * `[filepath, mode, perm]`: Redirects from or to the file at `filepath` via
|
212
|
+
# `open(filepath, mode, perm)`.
|
213
|
+
# * `[:child, fd]`: Redirects to the redirected `fd`.
|
214
|
+
# * `:close`: Closes the file descriptor in child process.
|
215
|
+
#
|
216
|
+
# See [Access Modes](rdoc-ref:File@Access+Modes) and [File
|
217
|
+
# Permissions](rdoc-ref:File@File+Permissions).
|
218
|
+
#
|
219
|
+
# #### Environment Variables (`:unsetenv_others`)
|
220
|
+
#
|
221
|
+
# By default, the new process inherits environment variables from the parent
|
222
|
+
# process; use execution option key `:unsetenv_others` with value `true` to
|
223
|
+
# clear environment variables in the new process.
|
224
|
+
#
|
225
|
+
# Any changes specified by execution option `env` are made after the new process
|
226
|
+
# inherits or clears its environment variables; see [Execution
|
227
|
+
# Environment](rdoc-ref:Process@Execution+Environment).
|
228
|
+
#
|
229
|
+
# #### File-Creation Access (`:umask`)
|
230
|
+
#
|
231
|
+
# Use execution option `:umask` to set the file-creation access for the new
|
232
|
+
# process; see [Access Modes](rdoc-ref:File@Access+Modes):
|
233
|
+
#
|
234
|
+
# command = 'ruby -e "puts sprintf(\"0%o\", File.umask)"'
|
235
|
+
# options = {:umask => 0644}
|
236
|
+
# Process.spawn(command, options)
|
237
|
+
#
|
238
|
+
# Output:
|
239
|
+
#
|
240
|
+
# 0644
|
241
|
+
#
|
242
|
+
# #### Process Groups (`:pgroup` and `:new_pgroup`)
|
243
|
+
#
|
244
|
+
# By default, the new process belongs to the same [process
|
245
|
+
# group](https://en.wikipedia.org/wiki/Process_group) as the parent process.
|
246
|
+
#
|
247
|
+
# To specify a different process group. use execution option `:pgroup` with one
|
248
|
+
# of the following values:
|
249
|
+
#
|
250
|
+
# * `true`: Create a new process group for the new process.
|
251
|
+
# * *pgid*: Create the new process in the process group whose id is *pgid*.
|
252
|
+
#
|
253
|
+
# On Windows only, use execution option `:new_pgroup` with value `true` to
|
254
|
+
# create a new process group for the new process.
|
255
|
+
#
|
256
|
+
# #### Resource Limits
|
257
|
+
#
|
258
|
+
# Use execution options to set resource limits.
|
259
|
+
#
|
260
|
+
# The keys for these options are symbols of the form `:rlimit_*resource_name`*,
|
261
|
+
# where *resource_name* is the downcased form of one of the string resource
|
262
|
+
# names described at method Process.setrlimit. For example, key `:rlimit_cpu`
|
263
|
+
# corresponds to resource limit `'CPU'`.
|
264
|
+
#
|
265
|
+
# The value for such as key is one of:
|
266
|
+
#
|
267
|
+
# * An integer, specifying both the current and maximum limits.
|
268
|
+
# * A 2-element array of integers, specifying the current and maximum limits.
|
269
|
+
#
|
270
|
+
# #### File Descriptor Inheritance
|
271
|
+
#
|
272
|
+
# By default, the new process inherits file descriptors from the parent process.
|
273
|
+
#
|
274
|
+
# Use execution option `:close_others => true` to modify that inheritance by
|
275
|
+
# closing non-standard fds (3 and greater) that are not otherwise redirected.
|
276
|
+
#
|
277
|
+
# ### Execution Shell
|
278
|
+
#
|
279
|
+
# On a Unix-like system, the shell invoked is `/bin/sh`; the entire string
|
280
|
+
# `command_line` is passed as an argument to [shell option
|
281
|
+
# -c](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh.
|
282
|
+
# html).
|
283
|
+
#
|
284
|
+
# The shell performs normal shell expansion on the command line:
|
285
|
+
#
|
286
|
+
# Example:
|
287
|
+
#
|
288
|
+
# system('echo $SHELL: C*') # => true
|
289
|
+
#
|
290
|
+
# Output:
|
291
|
+
#
|
292
|
+
# /bin/bash: CONTRIBUTING.md COPYING COPYING.ja
|
293
|
+
#
|
294
|
+
# #### Execution Shell on Windows
|
295
|
+
#
|
296
|
+
# On Windows, the shell invoked is determined by environment variable
|
297
|
+
# `RUBYSHELL`, if defined, or `COMSPEC` otherwise; the entire string
|
298
|
+
# `command_line` is passed as an argument to `-c` option for `RUBYSHELL`, as
|
299
|
+
# well as `/bin/sh`, and [/c
|
300
|
+
# option](https://learn.microsoft.com/en-us/windows-server/administration/window
|
301
|
+
# s-commands/cmd) for `COMSPEC`. The shell is invoked automatically in the
|
302
|
+
# following cases:
|
303
|
+
#
|
304
|
+
# * The command is a built-in of `cmd.exe`, such as `echo`.
|
305
|
+
# * The executable file is a batch file; its name ends with `.bat` or `.cmd`.
|
306
|
+
#
|
307
|
+
# Note that the command will still be invoked as `command_line` form even when
|
308
|
+
# called in `exe_path` form, because `cmd.exe` does not accept a script name
|
309
|
+
# like `/bin/sh` does but only works with `/c` option.
|
310
|
+
#
|
311
|
+
# The standard shell `cmd.exe` performs environment variable expansion but does
|
312
|
+
# not have globbing functionality:
|
313
|
+
#
|
314
|
+
# Example:
|
315
|
+
#
|
316
|
+
# system("echo %COMSPEC%: C*")' # => true
|
317
|
+
#
|
318
|
+
# Output:
|
319
|
+
#
|
320
|
+
# C:\WINDOWS\system32\cmd.exe: C*
|
321
|
+
#
|
322
|
+
# ## What's Here
|
323
|
+
#
|
324
|
+
# ### Current-Process Getters
|
325
|
+
#
|
326
|
+
# * ::argv0: Returns the process name as a frozen string.
|
327
|
+
# * ::egid: Returns the effective group ID.
|
328
|
+
# * ::euid: Returns the effective user ID.
|
329
|
+
# * ::getpgrp: Return the process group ID.
|
330
|
+
# * ::getrlimit: Returns the resource limit.
|
331
|
+
# * ::gid: Returns the (real) group ID.
|
332
|
+
# * ::pid: Returns the process ID.
|
333
|
+
# * ::ppid: Returns the process ID of the parent process.
|
334
|
+
# * ::uid: Returns the (real) user ID.
|
335
|
+
#
|
336
|
+
# ### Current-Process Setters
|
337
|
+
#
|
338
|
+
# * ::egid=: Sets the effective group ID.
|
339
|
+
# * ::euid=: Sets the effective user ID.
|
340
|
+
# * ::gid=: Sets the (real) group ID.
|
341
|
+
# * ::setproctitle: Sets the process title.
|
342
|
+
# * ::setpgrp: Sets the process group ID of the process to zero.
|
343
|
+
# * ::setrlimit: Sets a resource limit.
|
344
|
+
# * ::setsid: Establishes the process as a new session and process group
|
345
|
+
# leader, with no controlling tty.
|
346
|
+
# * ::uid=: Sets the user ID.
|
347
|
+
#
|
348
|
+
# ### Current-Process Execution
|
349
|
+
#
|
350
|
+
# * ::abort: Immediately terminates the process.
|
351
|
+
# * ::daemon: Detaches the process from its controlling terminal and continues
|
352
|
+
# running it in the background as system daemon.
|
353
|
+
# * ::exec: Replaces the process by running a given external command.
|
354
|
+
# * ::exit: Initiates process termination by raising exception SystemExit
|
355
|
+
# (which may be caught).
|
356
|
+
# * ::exit!: Immediately exits the process.
|
357
|
+
# * ::warmup: Notifies the Ruby virtual machine that the boot sequence for the
|
358
|
+
# application is completed, and that the VM may begin optimizing the
|
359
|
+
# application.
|
360
|
+
#
|
361
|
+
# ### Child Processes
|
362
|
+
#
|
363
|
+
# * ::detach: Guards against a child process becoming a zombie.
|
364
|
+
# * ::fork: Creates a child process.
|
365
|
+
# * ::kill: Sends a given signal to processes.
|
366
|
+
# * ::spawn: Creates a child process.
|
367
|
+
# * ::wait, ::waitpid: Waits for a child process to exit; returns its process
|
368
|
+
# ID.
|
369
|
+
# * ::wait2, ::waitpid2: Waits for a child process to exit; returns its
|
370
|
+
# process ID and status.
|
371
|
+
# * ::waitall: Waits for all child processes to exit; returns their process
|
372
|
+
# IDs and statuses.
|
373
|
+
#
|
374
|
+
# ### Process Groups
|
375
|
+
#
|
376
|
+
# * ::getpgid: Returns the process group ID for a process.
|
377
|
+
# * ::getpriority: Returns the scheduling priority for a process, process
|
378
|
+
# group, or user.
|
379
|
+
# * ::getsid: Returns the session ID for a process.
|
380
|
+
# * ::groups: Returns an array of the group IDs in the supplemental group
|
381
|
+
# access list for this process.
|
382
|
+
# * ::groups=: Sets the supplemental group access list to the given array of
|
383
|
+
# group IDs.
|
384
|
+
# * ::initgroups: Initializes the supplemental group access list.
|
385
|
+
# * ::last_status: Returns the status of the last executed child process in
|
386
|
+
# the current thread.
|
387
|
+
# * ::maxgroups: Returns the maximum number of group IDs allowed in the
|
388
|
+
# supplemental group access list.
|
389
|
+
# * ::maxgroups=: Sets the maximum number of group IDs allowed in the
|
390
|
+
# supplemental group access list.
|
391
|
+
# * ::setpgid: Sets the process group ID of a process.
|
392
|
+
# * ::setpriority: Sets the scheduling priority for a process, process group,
|
393
|
+
# or user.
|
394
|
+
#
|
395
|
+
# ### Timing
|
396
|
+
#
|
397
|
+
# * ::clock_getres: Returns the resolution of a system clock.
|
398
|
+
# * ::clock_gettime: Returns the time from a system clock.
|
399
|
+
# * ::times: Returns a Process::Tms object containing times for the current
|
400
|
+
# process and its child processes.
|
401
|
+
#
|
402
|
+
module Process
|
403
|
+
# <!--
|
404
|
+
# rdoc-file=process.c
|
405
|
+
# - Process._fork -> integer
|
406
|
+
# -->
|
407
|
+
# 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 `"-"`.
|
409
|
+
#
|
410
|
+
# This method is not for casual code but for application monitoring libraries.
|
411
|
+
# You can add custom code before and after fork events by overriding this
|
412
|
+
# method.
|
413
|
+
#
|
414
|
+
# Note: Process.daemon may be implemented using fork(2) BUT does not go through
|
415
|
+
# this method. Thus, depending on your reason to hook into this method, you may
|
416
|
+
# also want to hook into that one. See [this
|
417
|
+
# issue](https://bugs.ruby-lang.org/issues/18911) for a more detailed discussion
|
418
|
+
# of this.
|
419
|
+
#
|
420
|
+
def self._fork: () -> Integer
|
421
|
+
|
422
|
+
# <!--
|
423
|
+
# rdoc-file=ruby.c
|
424
|
+
# - Process.argv0 -> frozen_string
|
425
|
+
# -->
|
426
|
+
# Returns the name of the script being executed. The value is not affected by
|
427
|
+
# assigning a new value to $0.
|
428
|
+
#
|
429
|
+
# This method first appeared in Ruby 2.1 to serve as a global variable free
|
430
|
+
# means to get the script name.
|
431
|
+
#
|
432
|
+
def self.argv0: () -> String
|
433
|
+
|
434
|
+
# <!--
|
435
|
+
# rdoc-file=process.c
|
436
|
+
# - Process.clock_getres(clock_id, unit = :float_second) -> number
|
437
|
+
# -->
|
438
|
+
# Returns a clock resolution as determined by POSIX function
|
439
|
+
# [clock_getres()](https://man7.org/linux/man-pages/man3/clock_getres.3.html):
|
440
|
+
#
|
441
|
+
# Process.clock_getres(:CLOCK_REALTIME) # => 1.0e-09
|
442
|
+
#
|
443
|
+
# See Process.clock_gettime for the values of `clock_id` and `unit`.
|
444
|
+
#
|
445
|
+
# Examples:
|
446
|
+
#
|
447
|
+
# Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_microsecond) # => 0.001
|
448
|
+
# Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_millisecond) # => 1.0e-06
|
449
|
+
# Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_second) # => 1.0e-09
|
450
|
+
# Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :microsecond) # => 0
|
451
|
+
# Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :millisecond) # => 0
|
452
|
+
# Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :nanosecond) # => 1
|
453
|
+
# Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :second) # => 0
|
454
|
+
#
|
455
|
+
# In addition to the values for `unit` supported in Process.clock_gettime, this
|
456
|
+
# method supports `:hertz`, the integer number of clock ticks per second (which
|
457
|
+
# is the reciprocal of `:float_second`):
|
458
|
+
#
|
459
|
+
# Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) # => 100.0
|
460
|
+
# Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :float_second) # => 0.01
|
461
|
+
#
|
462
|
+
# **Accuracy**: Note that the returned resolution may be inaccurate on some
|
463
|
+
# platforms due to underlying bugs. Inaccurate resolutions have been reported
|
464
|
+
# for various clocks including `:CLOCK_MONOTONIC` and `:CLOCK_MONOTONIC_RAW` on
|
465
|
+
# Linux, macOS, BSD or AIX platforms, when using ARM processors, or when using
|
466
|
+
# virtualization.
|
467
|
+
#
|
468
|
+
def self.clock_getres: (Symbol | Integer clock_id, ?Symbol unit) -> (Float | Integer)
|
469
|
+
|
470
|
+
# <!--
|
471
|
+
# rdoc-file=process.c
|
472
|
+
# - Process.clock_gettime(clock_id, unit = :float_second) -> number
|
473
|
+
# -->
|
474
|
+
# Returns a clock time as determined by POSIX function
|
475
|
+
# [clock_gettime()](https://man7.org/linux/man-pages/man3/clock_gettime.3.html):
|
476
|
+
#
|
477
|
+
# Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID) # => 198.650379677
|
478
|
+
#
|
479
|
+
# Argument `clock_id` should be a symbol or a constant that specifies the clock
|
480
|
+
# whose time is to be returned; see below.
|
481
|
+
#
|
482
|
+
# Optional argument `unit` should be a symbol that specifies the unit to be used
|
483
|
+
# in the returned clock time; see below.
|
484
|
+
#
|
485
|
+
# **Argument `clock_id`**
|
486
|
+
#
|
487
|
+
# Argument `clock_id` specifies the clock whose time is to be returned; it may
|
488
|
+
# be a constant such as `Process::CLOCK_REALTIME`, or a symbol shorthand such as
|
489
|
+
# `:CLOCK_REALTIME`.
|
490
|
+
#
|
491
|
+
# The supported clocks depend on the underlying operating system; this method
|
492
|
+
# supports the following clocks on the indicated platforms (raises Errno::EINVAL
|
493
|
+
# if called with an unsupported clock):
|
494
|
+
#
|
495
|
+
# * `:CLOCK_BOOTTIME`: Linux 2.6.39.
|
496
|
+
# * `:CLOCK_BOOTTIME_ALARM`: Linux 3.0.
|
497
|
+
# * `:CLOCK_MONOTONIC`: SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0,
|
498
|
+
# OpenBSD 3.4, macOS 10.12, Windows-2000.
|
499
|
+
# * `:CLOCK_MONOTONIC_COARSE`: Linux 2.6.32.
|
500
|
+
# * `:CLOCK_MONOTONIC_FAST`: FreeBSD 8.1.
|
501
|
+
# * `:CLOCK_MONOTONIC_PRECISE`: FreeBSD 8.1.
|
502
|
+
# * `:CLOCK_MONOTONIC_RAW`: Linux 2.6.28, macOS 10.12.
|
503
|
+
# * `:CLOCK_MONOTONIC_RAW_APPROX`: macOS 10.12.
|
504
|
+
# * `:CLOCK_PROCESS_CPUTIME_ID`: SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3,
|
505
|
+
# OpenBSD 5.4, macOS 10.12.
|
506
|
+
# * `:CLOCK_PROF`: FreeBSD 3.0, OpenBSD 2.1.
|
507
|
+
# * `:CLOCK_REALTIME`: SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0,
|
508
|
+
# OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012. Time.now is recommended
|
509
|
+
# over +:CLOCK_REALTIME:.
|
510
|
+
# * `:CLOCK_REALTIME_ALARM`: Linux 3.0.
|
511
|
+
# * `:CLOCK_REALTIME_COARSE`: Linux 2.6.32.
|
512
|
+
# * `:CLOCK_REALTIME_FAST`: FreeBSD 8.1.
|
513
|
+
# * `:CLOCK_REALTIME_PRECISE`: FreeBSD 8.1.
|
514
|
+
# * `:CLOCK_SECOND`: FreeBSD 8.1.
|
515
|
+
# * `:CLOCK_TAI`: Linux 3.10.
|
516
|
+
# * `:CLOCK_THREAD_CPUTIME_ID`: SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD
|
517
|
+
# 5.4, macOS 10.12.
|
518
|
+
# * `:CLOCK_UPTIME`: FreeBSD 7.0, OpenBSD 5.5.
|
519
|
+
# * `:CLOCK_UPTIME_FAST`: FreeBSD 8.1.
|
520
|
+
# * `:CLOCK_UPTIME_PRECISE`: FreeBSD 8.1.
|
521
|
+
# * `:CLOCK_UPTIME_RAW`: macOS 10.12.
|
522
|
+
# * `:CLOCK_UPTIME_RAW_APPROX`: macOS 10.12.
|
523
|
+
# * `:CLOCK_VIRTUAL`: FreeBSD 3.0, OpenBSD 2.1.
|
524
|
+
#
|
525
|
+
# Note that SUS stands for Single Unix Specification. SUS contains POSIX and
|
526
|
+
# clock_gettime is defined in the POSIX part. SUS defines `:CLOCK_REALTIME` as
|
527
|
+
# mandatory but `:CLOCK_MONOTONIC`, `:CLOCK_PROCESS_CPUTIME_ID`, and
|
528
|
+
# `:CLOCK_THREAD_CPUTIME_ID` are optional.
|
529
|
+
#
|
530
|
+
# Certain emulations are used when the given `clock_id` is not supported
|
531
|
+
# directly:
|
532
|
+
#
|
533
|
+
# * Emulations for `:CLOCK_REALTIME`:
|
534
|
+
#
|
535
|
+
# * `:GETTIMEOFDAY_BASED_CLOCK_REALTIME`: Use gettimeofday() defined by
|
536
|
+
# SUS (deprecated in SUSv4). The resolution is 1 microsecond.
|
537
|
+
# * `:TIME_BASED_CLOCK_REALTIME`: Use time() defined by ISO C. The
|
538
|
+
# resolution is 1 second.
|
539
|
+
#
|
540
|
+
# * Emulations for `:CLOCK_MONOTONIC`:
|
541
|
+
#
|
542
|
+
# * `:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC`: Use mach_absolute_time(),
|
543
|
+
# available on Darwin. The resolution is CPU dependent.
|
544
|
+
# * `:TIMES_BASED_CLOCK_MONOTONIC`: Use the result value of times()
|
545
|
+
# defined by POSIX, thus:
|
546
|
+
# > Upon successful completion, times() shall return the elapsed real
|
547
|
+
# time, in clock ticks, since an arbitrary point in the past (for
|
548
|
+
# example, system start-up time).
|
549
|
+
#
|
550
|
+
# > For example, GNU/Linux returns a value based on jiffies and it is
|
551
|
+
# monotonic. However, 4.4BSD uses gettimeofday() and it is not
|
552
|
+
# monotonic. (FreeBSD uses `:CLOCK_MONOTONIC` instead, though.)
|
553
|
+
#
|
554
|
+
# The resolution is the clock tick. "getconf CLK_TCK" command shows the
|
555
|
+
# clock ticks per second. (The clock ticks-per-second is defined by HZ
|
556
|
+
# macro in older systems.) If it is 100 and clock_t is 32 bits integer
|
557
|
+
# type, the resolution is 10 millisecond and cannot represent over 497
|
558
|
+
# days.
|
559
|
+
#
|
560
|
+
# * Emulations for `:CLOCK_PROCESS_CPUTIME_ID`:
|
561
|
+
#
|
562
|
+
# * `:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID`: Use getrusage() defined
|
563
|
+
# by SUS. getrusage() is used with RUSAGE_SELF to obtain the time only
|
564
|
+
# for the calling process (excluding the time for child processes). The
|
565
|
+
# result is addition of user time (ru_utime) and system time (ru_stime).
|
566
|
+
# The resolution is 1 microsecond.
|
567
|
+
# * `:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID`: Use times() defined by POSIX.
|
568
|
+
# The result is addition of user time (tms_utime) and system time
|
569
|
+
# (tms_stime). tms_cutime and tms_cstime are ignored to exclude the time
|
570
|
+
# for child processes. The resolution is the clock tick. "getconf
|
571
|
+
# CLK_TCK" command shows the clock ticks per second. (The clock ticks
|
572
|
+
# per second is defined by HZ macro in older systems.) If it is 100, the
|
573
|
+
# resolution is 10 millisecond.
|
574
|
+
# * `:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID`: Use clock() defined by ISO C.
|
575
|
+
# The resolution is `1/CLOCKS_PER_SEC`. `CLOCKS_PER_SEC` is the C-level
|
576
|
+
# macro defined by time.h. SUS defines `CLOCKS_PER_SEC` as 1000000;
|
577
|
+
# other systems may define it differently. If `CLOCKS_PER_SEC` is
|
578
|
+
# 1000000 (as in SUS), the resolution is 1 microsecond. If
|
579
|
+
# `CLOCKS_PER_SEC` is 1000000 and clock_t is a 32-bit integer type, it
|
580
|
+
# cannot represent over 72 minutes.
|
581
|
+
#
|
582
|
+
# **Argument `unit`**
|
583
|
+
#
|
584
|
+
# Optional argument `unit` (default `:float_second`) specifies the unit for the
|
585
|
+
# returned value.
|
586
|
+
#
|
587
|
+
# * `:float_microsecond`: Number of microseconds as a float.
|
588
|
+
# * `:float_millisecond`: Number of milliseconds as a float.
|
589
|
+
# * `:float_second`: Number of seconds as a float.
|
590
|
+
# * `:microsecond`: Number of microseconds as an integer.
|
591
|
+
# * `:millisecond`: Number of milliseconds as an integer.
|
592
|
+
# * `:nanosecond`: Number of nanoseconds as an integer.
|
593
|
+
# * `::second`: Number of seconds as an integer.
|
594
|
+
#
|
595
|
+
# Examples:
|
596
|
+
#
|
597
|
+
# Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_microsecond)
|
598
|
+
# # => 203605054.825
|
599
|
+
# Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_millisecond)
|
600
|
+
# # => 203643.696848
|
601
|
+
# Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_second)
|
602
|
+
# # => 203.762181929
|
603
|
+
# Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :microsecond)
|
604
|
+
# # => 204123212
|
605
|
+
# Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :millisecond)
|
606
|
+
# # => 204298
|
607
|
+
# Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :nanosecond)
|
608
|
+
# # => 204602286036
|
609
|
+
# Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :second)
|
610
|
+
# # => 204
|
611
|
+
#
|
612
|
+
# The underlying function, clock_gettime(), returns a number of nanoseconds.
|
613
|
+
# Float object (IEEE 754 double) is not enough to represent the return value for
|
614
|
+
# `:CLOCK_REALTIME`. If the exact nanoseconds value is required, use
|
615
|
+
# `:nanosecond` as the `unit`.
|
616
|
+
#
|
617
|
+
# The origin (time zero) of the returned value is system-dependent, and may be,
|
618
|
+
# for example, system start up time, process start up time, the Epoch, etc.
|
619
|
+
#
|
620
|
+
# The origin in `:CLOCK_REALTIME` is defined as the Epoch: `1970-01-01 00:00:00
|
621
|
+
# UTC`; some systems count leap seconds and others don't, so the result may vary
|
622
|
+
# across systems.
|
623
|
+
#
|
624
|
+
def self.clock_gettime: (Symbol | Integer clock_id) -> Float
|
625
|
+
| (Symbol | Integer clock_id, :float_second | :float_millisecond | :float_microsecond unit) -> Float
|
626
|
+
| (Symbol | Integer clock_id, :second | :millisecond | :microsecond | :nanosecond unit) -> Integer
|
627
|
+
|
628
|
+
# <!--
|
629
|
+
# rdoc-file=process.c
|
630
|
+
# - Process.daemon(nochdir = nil, noclose = nil) -> 0
|
631
|
+
# -->
|
632
|
+
# Detaches the current process from its controlling terminal and runs it in the
|
633
|
+
# background as system daemon; returns zero.
|
634
|
+
#
|
635
|
+
# By default:
|
636
|
+
#
|
637
|
+
# * Changes the current working directory to the root directory.
|
638
|
+
# * Redirects $stdin, $stdout, and $stderr to the null device.
|
639
|
+
#
|
640
|
+
# If optional argument `nochdir` is `true`, does not change the current working
|
641
|
+
# directory.
|
642
|
+
#
|
643
|
+
# If optional argument `noclose` is `true`, does not redirect $stdin, $stdout,
|
644
|
+
# or $stderr.
|
645
|
+
#
|
646
|
+
def self.daemon: (?untyped nochdir, ?untyped noclose) -> Integer
|
647
|
+
|
648
|
+
# <!--
|
649
|
+
# rdoc-file=process.c
|
650
|
+
# - Process.detach(pid) -> thread
|
651
|
+
# -->
|
652
|
+
# Avoids the potential for a child process to become a [zombie
|
653
|
+
# process](https://en.wikipedia.org/wiki/Zombie_process). Process.detach
|
654
|
+
# prevents this by setting up a separate Ruby thread whose sole job is to reap
|
655
|
+
# the status of the process *pid* when it terminates.
|
656
|
+
#
|
657
|
+
# This method is needed only when the parent process will never wait for the
|
658
|
+
# child process.
|
659
|
+
#
|
660
|
+
# This example does not reap the second child process; that process appears as a
|
661
|
+
# zombie in the process status (`ps`) output:
|
662
|
+
#
|
663
|
+
# pid = Process.spawn('ruby', '-e', 'exit 13') # => 312691
|
664
|
+
# sleep(1)
|
665
|
+
# # Find zombies.
|
666
|
+
# system("ps -ho pid,state -p #{pid}")
|
667
|
+
#
|
668
|
+
# Output:
|
669
|
+
#
|
670
|
+
# 312716 Z
|
671
|
+
#
|
672
|
+
# This example also does not reap the second child process, but it does detach
|
673
|
+
# the process so that it does not become a zombie:
|
674
|
+
#
|
675
|
+
# pid = Process.spawn('ruby', '-e', 'exit 13') # => 313213
|
676
|
+
# thread = Process.detach(pid)
|
677
|
+
# sleep(1)
|
678
|
+
# # => #<Process::Waiter:0x00007f038f48b838 run>
|
679
|
+
# system("ps -ho pid,state -p #{pid}") # Finds no zombies.
|
680
|
+
#
|
681
|
+
# The waiting thread can return the pid of the detached child process:
|
682
|
+
#
|
683
|
+
# thread.join.pid # => 313262
|
684
|
+
#
|
685
|
+
def self.detach: (Integer pid) -> Process::Waiter
|
686
|
+
|
687
|
+
# <!--
|
688
|
+
# rdoc-file=process.c
|
689
|
+
# - Process.egid -> integer
|
690
|
+
# - Process::GID.eid -> integer
|
691
|
+
# - Process::Sys.geteid -> integer
|
692
|
+
# -->
|
693
|
+
# Returns the effective group ID for the current process:
|
694
|
+
#
|
695
|
+
# Process.egid # => 500
|
696
|
+
#
|
697
|
+
# Not available on all platforms.
|
698
|
+
#
|
699
|
+
def self.egid: () -> Integer
|
700
|
+
|
701
|
+
# <!--
|
702
|
+
# rdoc-file=process.c
|
703
|
+
# - Process.egid = new_egid -> new_egid
|
704
|
+
# -->
|
705
|
+
# Sets the effective group ID for the current process.
|
706
|
+
#
|
707
|
+
# Not available on all platforms.
|
708
|
+
#
|
709
|
+
def self.egid=: (Integer arg0) -> Integer
|
710
|
+
|
711
|
+
# <!--
|
712
|
+
# rdoc-file=process.c
|
713
|
+
# - Process.euid -> integer
|
714
|
+
# - Process::UID.eid -> integer
|
715
|
+
# - Process::Sys.geteuid -> integer
|
716
|
+
# -->
|
717
|
+
# Returns the effective user ID for the current process.
|
718
|
+
#
|
719
|
+
# Process.euid # => 501
|
720
|
+
#
|
721
|
+
def self.euid: () -> Integer
|
722
|
+
|
723
|
+
# <!--
|
724
|
+
# rdoc-file=process.c
|
725
|
+
# - Process.euid = new_euid -> new_euid
|
726
|
+
# -->
|
727
|
+
# Sets the effective user ID for the current process.
|
728
|
+
#
|
729
|
+
# Not available on all platforms.
|
730
|
+
#
|
731
|
+
def self.euid=: (Integer arg0) -> Integer
|
732
|
+
|
733
|
+
# <!--
|
734
|
+
# rdoc-file=process.c
|
735
|
+
# - Process.getpgid(pid) -> integer
|
736
|
+
# -->
|
737
|
+
# Returns the process group ID for the given process ID +pid+:
|
738
|
+
#
|
739
|
+
# Process.getpgid(Process.ppid) # => 25527
|
740
|
+
#
|
741
|
+
# Not available on all platforms.
|
742
|
+
#
|
743
|
+
def self.getpgid: (Integer pid) -> Integer
|
744
|
+
|
745
|
+
# <!--
|
746
|
+
# rdoc-file=process.c
|
747
|
+
# - Process.getpgrp -> integer
|
748
|
+
# -->
|
749
|
+
# Returns the process group ID for the current process:
|
750
|
+
#
|
751
|
+
# Process.getpgid(0) # => 25527
|
752
|
+
# Process.getpgrp # => 25527
|
753
|
+
#
|
754
|
+
def self.getpgrp: () -> Integer
|
755
|
+
|
756
|
+
# <!--
|
757
|
+
# rdoc-file=process.c
|
758
|
+
# - Process.getpriority(kind, id) -> integer
|
759
|
+
# -->
|
760
|
+
# Returns the scheduling priority for specified process, process group, or user.
|
761
|
+
#
|
762
|
+
# Argument `kind` is one of:
|
763
|
+
#
|
764
|
+
# * Process::PRIO_PROCESS: return priority for process.
|
765
|
+
# * Process::PRIO_PGRP: return priority for process group.
|
766
|
+
# * Process::PRIO_USER: return priority for user.
|
767
|
+
#
|
768
|
+
# Argument `id` is the ID for the process, process group, or user; zero
|
769
|
+
# specified the current ID for `kind`.
|
770
|
+
#
|
771
|
+
# Examples:
|
772
|
+
#
|
773
|
+
# Process.getpriority(Process::PRIO_USER, 0) # => 19
|
774
|
+
# Process.getpriority(Process::PRIO_PROCESS, 0) # => 19
|
775
|
+
#
|
776
|
+
# Not available on all platforms.
|
777
|
+
#
|
778
|
+
def self.getpriority: (Integer kind, Integer arg0) -> Integer
|
779
|
+
|
780
|
+
# <!--
|
781
|
+
# rdoc-file=process.c
|
782
|
+
# - Process.getrlimit(resource) -> [cur_limit, max_limit]
|
783
|
+
# -->
|
784
|
+
# Returns a 2-element array of the current (soft) limit and maximum (hard) limit
|
785
|
+
# for the given `resource`.
|
786
|
+
#
|
787
|
+
# Argument `resource` specifies the resource whose limits are to be returned;
|
788
|
+
# see Process.setrlimit.
|
789
|
+
#
|
790
|
+
# Each of the returned values `cur_limit` and `max_limit` is an integer; see
|
791
|
+
# Process.setrlimit.
|
792
|
+
#
|
793
|
+
# Example:
|
794
|
+
#
|
795
|
+
# Process.getrlimit(:CORE) # => [0, 18446744073709551615]
|
796
|
+
#
|
797
|
+
# See Process.setrlimit.
|
798
|
+
#
|
799
|
+
# Not available on all platforms.
|
800
|
+
#
|
801
|
+
def self.getrlimit: (interned | Integer resource) -> [ Integer, Integer ]
|
802
|
+
|
803
|
+
# <!--
|
804
|
+
# rdoc-file=process.c
|
805
|
+
# - Process.getsid(pid = nil) -> integer
|
806
|
+
# -->
|
807
|
+
# Returns the session ID of the given process ID `pid`, or of the current
|
808
|
+
# process if not given:
|
809
|
+
#
|
810
|
+
# Process.getsid # => 27422
|
811
|
+
# Process.getsid(0) # => 27422
|
812
|
+
# Process.getsid(Process.pid()) # => 27422
|
813
|
+
#
|
814
|
+
# Not available on all platforms.
|
815
|
+
#
|
816
|
+
def self.getsid: (?Integer pid) -> Integer
|
817
|
+
|
818
|
+
# <!--
|
819
|
+
# rdoc-file=process.c
|
820
|
+
# - Process.gid -> integer
|
821
|
+
# - Process::GID.rid -> integer
|
822
|
+
# - Process::Sys.getgid -> integer
|
823
|
+
# -->
|
824
|
+
# Returns the (real) group ID for the current process:
|
825
|
+
#
|
826
|
+
# Process.gid # => 1000
|
827
|
+
#
|
828
|
+
def self.gid: () -> Integer
|
829
|
+
|
830
|
+
# <!--
|
831
|
+
# rdoc-file=process.c
|
832
|
+
# - Process.gid = new_gid -> new_gid
|
833
|
+
# -->
|
834
|
+
# Sets the group ID for the current process to `new_gid`:
|
835
|
+
#
|
836
|
+
# Process.gid = 1000 # => 1000
|
837
|
+
#
|
838
|
+
def self.gid=: (Integer arg0) -> Integer
|
839
|
+
|
840
|
+
# <!--
|
841
|
+
# rdoc-file=process.c
|
842
|
+
# - Process.groups -> array
|
843
|
+
# -->
|
844
|
+
# Returns an array of the group IDs in the supplemental group access list for
|
845
|
+
# the current process:
|
846
|
+
#
|
847
|
+
# Process.groups # => [4, 24, 27, 30, 46, 122, 135, 136, 1000]
|
848
|
+
#
|
849
|
+
# These properties of the returned array are system-dependent:
|
850
|
+
#
|
851
|
+
# * Whether (and how) the array is sorted.
|
852
|
+
# * Whether the array includes effective group IDs.
|
853
|
+
# * Whether the array includes duplicate group IDs.
|
854
|
+
# * Whether the array size exceeds the value of Process.maxgroups.
|
855
|
+
#
|
856
|
+
# Use this call to get a sorted and unique array:
|
857
|
+
#
|
858
|
+
# Process.groups.uniq.sort
|
859
|
+
#
|
860
|
+
def self.groups: () -> ::Array[Integer]
|
861
|
+
|
862
|
+
# <!--
|
863
|
+
# rdoc-file=process.c
|
864
|
+
# - Process.groups = new_groups -> new_groups
|
865
|
+
# -->
|
866
|
+
# Sets the supplemental group access list to the given array of group IDs.
|
867
|
+
#
|
868
|
+
# Process.groups # => [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
|
869
|
+
# Process.groups = [27, 6, 10, 11] # => [27, 6, 10, 11]
|
870
|
+
# Process.groups # => [27, 6, 10, 11]
|
871
|
+
#
|
872
|
+
def self.groups=: (::Array[Integer] arg0) -> ::Array[Integer]
|
873
|
+
|
874
|
+
# <!--
|
875
|
+
# rdoc-file=process.c
|
876
|
+
# - Process.initgroups(username, gid) -> array
|
877
|
+
# -->
|
878
|
+
# Sets the supplemental group access list; the new list includes:
|
879
|
+
#
|
880
|
+
# * The group IDs of those groups to which the user given by `username`
|
881
|
+
# belongs.
|
882
|
+
# * The group ID `gid`.
|
883
|
+
#
|
884
|
+
# Example:
|
885
|
+
#
|
886
|
+
# Process.groups # => [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
|
887
|
+
# Process.initgroups('me', 30) # => [30, 6, 10, 11]
|
888
|
+
# Process.groups # => [30, 6, 10, 11]
|
889
|
+
#
|
890
|
+
# Not available on all platforms.
|
891
|
+
#
|
892
|
+
def self.initgroups: (String username, Integer gid) -> ::Array[Integer]
|
893
|
+
|
894
|
+
# <!--
|
895
|
+
# rdoc-file=process.c
|
896
|
+
# - Process.kill(signal, *ids) -> count
|
897
|
+
# -->
|
898
|
+
# Sends a signal to each process specified by `ids` (which must specify at least
|
899
|
+
# one ID); returns the count of signals sent.
|
900
|
+
#
|
901
|
+
# For each given `id`, if `id` is:
|
902
|
+
#
|
903
|
+
# * Positive, sends the signal to the process whose process ID is `id`.
|
904
|
+
# * Zero, send the signal to all processes in the current process group.
|
905
|
+
# * Negative, sends the signal to a system-dependent collection of processes.
|
906
|
+
#
|
907
|
+
# Argument `signal` specifies the signal to be sent; the argument may be:
|
908
|
+
#
|
909
|
+
# * An integer signal number: e.g., `-29`, `0`, `29`.
|
910
|
+
# * A signal name (string), with or without leading `'SIG'`, and with or
|
911
|
+
# without a further prefixed minus sign (`'-'`): e.g.:
|
912
|
+
#
|
913
|
+
# * `'SIGPOLL'`.
|
914
|
+
# * `'POLL'`,
|
915
|
+
# * `'-SIGPOLL'`.
|
916
|
+
# * `'-POLL'`.
|
917
|
+
#
|
918
|
+
# * A signal symbol, with or without leading `'SIG'`, and with or without a
|
919
|
+
# further prefixed minus sign (`'-'`): e.g.:
|
920
|
+
#
|
921
|
+
# * `:SIGPOLL`.
|
922
|
+
# * `:POLL`.
|
923
|
+
# * `:'-SIGPOLL'`.
|
924
|
+
# * `:'-POLL'`.
|
925
|
+
#
|
926
|
+
# If `signal` is:
|
927
|
+
#
|
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 `'-'`, each
|
931
|
+
# process group with group ID `id` is signalled.
|
932
|
+
#
|
933
|
+
# Use method Signal.list to see which signals are supported by Ruby on the
|
934
|
+
# underlying platform; the method returns a hash of the string names and
|
935
|
+
# non-negative integer values of the supported signals. The size and content of
|
936
|
+
# the returned hash varies widely among platforms.
|
937
|
+
#
|
938
|
+
# Additionally, signal `0` is useful to determine if the process exists.
|
939
|
+
#
|
940
|
+
# Example:
|
941
|
+
#
|
942
|
+
# pid = fork do
|
943
|
+
# Signal.trap('HUP') { puts 'Ouch!'; exit }
|
944
|
+
# # ... do some work ...
|
945
|
+
# end
|
946
|
+
# # ...
|
947
|
+
# Process.kill('HUP', pid)
|
948
|
+
# Process.wait
|
949
|
+
#
|
950
|
+
# Output:
|
951
|
+
#
|
952
|
+
# Ouch!
|
953
|
+
#
|
954
|
+
# Exceptions:
|
955
|
+
#
|
956
|
+
# * Raises Errno::EINVAL or RangeError if `signal` is an integer but invalid.
|
957
|
+
# * Raises ArgumentError if `signal` is a string or symbol but invalid.
|
958
|
+
# * Raises Errno::ESRCH or RangeError if one of `ids` is invalid.
|
959
|
+
# * Raises Errno::EPERM if needed permissions are not in force.
|
960
|
+
#
|
961
|
+
# In the last two cases, signals may have been sent to some processes.
|
962
|
+
#
|
963
|
+
def self.kill: (Integer | interned signal, *Integer pids) -> Integer
|
964
|
+
|
965
|
+
# <!--
|
966
|
+
# rdoc-file=process.c
|
967
|
+
# - Process.maxgroups -> integer
|
968
|
+
# -->
|
969
|
+
# Returns the maximum number of group IDs allowed in the supplemental group
|
970
|
+
# access list:
|
971
|
+
#
|
972
|
+
# Process.maxgroups # => 32
|
973
|
+
#
|
974
|
+
def self.maxgroups: () -> Integer
|
975
|
+
|
976
|
+
# <!--
|
977
|
+
# rdoc-file=process.c
|
978
|
+
# - Process.maxgroups = new_max -> new_max
|
979
|
+
# -->
|
980
|
+
# Sets the maximum number of group IDs allowed in the supplemental group access
|
981
|
+
# list.
|
982
|
+
#
|
983
|
+
def self.maxgroups=: (Integer arg0) -> Integer
|
984
|
+
|
985
|
+
# <!--
|
986
|
+
# rdoc-file=process.c
|
987
|
+
# - Process.pid -> integer
|
988
|
+
# -->
|
989
|
+
# Returns the process ID of the current process:
|
990
|
+
#
|
991
|
+
# Process.pid # => 15668
|
992
|
+
#
|
993
|
+
def self.pid: () -> Integer
|
994
|
+
|
995
|
+
# <!--
|
996
|
+
# rdoc-file=process.c
|
997
|
+
# - Process.ppid -> integer
|
998
|
+
# -->
|
999
|
+
# Returns the process ID of the parent of the current process:
|
1000
|
+
#
|
1001
|
+
# puts "Pid is #{Process.pid}."
|
1002
|
+
# fork { puts "Parent pid is #{Process.ppid}." }
|
1003
|
+
#
|
1004
|
+
# Output:
|
1005
|
+
#
|
1006
|
+
# Pid is 271290.
|
1007
|
+
# Parent pid is 271290.
|
1008
|
+
#
|
1009
|
+
# May not return a trustworthy value on certain platforms.
|
1010
|
+
#
|
1011
|
+
def self.ppid: () -> Integer
|
1012
|
+
|
1013
|
+
# <!--
|
1014
|
+
# rdoc-file=process.c
|
1015
|
+
# - Process.setpgid(pid, pgid) -> 0
|
1016
|
+
# -->
|
1017
|
+
# Sets the process group ID for the process given by process ID `pid` to `pgid`.
|
1018
|
+
#
|
1019
|
+
# Not available on all platforms.
|
1020
|
+
#
|
1021
|
+
def self.setpgid: (Integer pid, Integer arg0) -> Integer
|
1022
|
+
|
1023
|
+
# <!--
|
1024
|
+
# rdoc-file=process.c
|
1025
|
+
# - Process.setpriority(kind, integer, priority) -> 0
|
1026
|
+
# -->
|
1027
|
+
# See Process.getpriority.
|
1028
|
+
#
|
1029
|
+
# Examples:
|
1030
|
+
#
|
1031
|
+
# Process.setpriority(Process::PRIO_USER, 0, 19) # => 0
|
1032
|
+
# Process.setpriority(Process::PRIO_PROCESS, 0, 19) # => 0
|
1033
|
+
# Process.getpriority(Process::PRIO_USER, 0) # => 19
|
1034
|
+
# Process.getpriority(Process::PRIO_PROCESS, 0) # => 19
|
1035
|
+
#
|
1036
|
+
# Not available on all platforms.
|
1037
|
+
#
|
1038
|
+
def self.setpriority: (Integer kind, Integer arg0, Integer priority) -> Integer
|
1039
|
+
|
1040
|
+
# <!--
|
1041
|
+
# rdoc-file=ruby.c
|
1042
|
+
# - Process.setproctitle(string) -> string
|
1043
|
+
# -->
|
1044
|
+
# Sets the process title that appears on the ps(1) command. Not necessarily
|
1045
|
+
# effective on all platforms. No exception will be raised regardless of the
|
1046
|
+
# result, nor will NotImplementedError be raised even if the platform does not
|
1047
|
+
# support the feature.
|
1048
|
+
#
|
1049
|
+
# Calling this method does not affect the value of $0.
|
1050
|
+
#
|
1051
|
+
# Process.setproctitle('myapp: worker #%d' % worker_id)
|
1052
|
+
#
|
1053
|
+
# This method first appeared in Ruby 2.1 to serve as a global variable free
|
1054
|
+
# means to change the process title.
|
1055
|
+
#
|
1056
|
+
def self.setproctitle: (String arg0) -> String
|
1057
|
+
|
1058
|
+
# <!--
|
1059
|
+
# rdoc-file=process.c
|
1060
|
+
# - Process.setrlimit(resource, cur_limit, max_limit = cur_limit) -> nil
|
1061
|
+
# -->
|
1062
|
+
# Sets limits for the current process for the given `resource` to `cur_limit`
|
1063
|
+
# (soft limit) and `max_limit` (hard limit); returns `nil`.
|
1064
|
+
#
|
1065
|
+
# Argument `resource` specifies the resource whose limits are to be set; the
|
1066
|
+
# argument may be given as a symbol, as a string, or as a constant beginning
|
1067
|
+
# with `Process::RLIMIT_` (e.g., `:CORE`, `'CORE'`, or `Process::RLIMIT_CORE`.
|
1068
|
+
#
|
1069
|
+
# The resources available and supported are system-dependent, and may include
|
1070
|
+
# (here expressed as symbols):
|
1071
|
+
#
|
1072
|
+
# * `:AS`: Total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD
|
1073
|
+
# except 4.4BSD-Lite).
|
1074
|
+
# * `:CORE`: Core size (bytes) (SUSv3).
|
1075
|
+
# * `:CPU`: CPU time (seconds) (SUSv3).
|
1076
|
+
# * `:DATA`: Data segment (bytes) (SUSv3).
|
1077
|
+
# * `:FSIZE`: File size (bytes) (SUSv3).
|
1078
|
+
# * `:MEMLOCK`: Total size for mlock(2) (bytes) (4.4BSD, GNU/Linux).
|
1079
|
+
# * `:MSGQUEUE`: Allocation for POSIX message queues (bytes) (GNU/Linux).
|
1080
|
+
# * `:NICE`: Ceiling on process's nice(2) value (number) (GNU/Linux).
|
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)
|
1086
|
+
# (GNU/Linux).
|
1087
|
+
# * `:RTTIME`: CPU time for real-time process (us) (GNU/Linux).
|
1088
|
+
# * `:SBSIZE`: All socket buffers (bytes) (NetBSD, FreeBSD).
|
1089
|
+
# * `:SIGPENDING`: Number of queued signals allowed (signals) (GNU/Linux).
|
1090
|
+
# * `:STACK`: Stack size (bytes) (SUSv3).
|
1091
|
+
#
|
1092
|
+
# Arguments `cur_limit` and `max_limit` may be:
|
1093
|
+
#
|
1094
|
+
# * Integers (`max_limit` should not be smaller than `cur_limit`).
|
1095
|
+
# * Symbol `:SAVED_MAX`, string `'SAVED_MAX'`, or constant
|
1096
|
+
# `Process::RLIM_SAVED_MAX`: saved maximum limit.
|
1097
|
+
# * Symbol `:SAVED_CUR`, string `'SAVED_CUR'`, or constant
|
1098
|
+
# `Process::RLIM_SAVED_CUR`: saved current limit.
|
1099
|
+
# * Symbol `:INFINITY`, string `'INFINITY'`, or constant
|
1100
|
+
# `Process::RLIM_INFINITY`: no limit on resource.
|
1101
|
+
#
|
1102
|
+
# This example raises the soft limit of core size to the hard limit to try to
|
1103
|
+
# make core dump possible:
|
1104
|
+
#
|
1105
|
+
# Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1])
|
1106
|
+
#
|
1107
|
+
# Not available on all platforms.
|
1108
|
+
#
|
1109
|
+
def self.setrlimit: (interned | Integer resource, Integer cur_limit, ?Integer max_limit) -> nil
|
1110
|
+
|
1111
|
+
# <!--
|
1112
|
+
# rdoc-file=process.c
|
1113
|
+
# - Process.setsid -> integer
|
1114
|
+
# -->
|
1115
|
+
# Establishes the current process as a new session and process group leader,
|
1116
|
+
# with no controlling tty; returns the session ID:
|
1117
|
+
#
|
1118
|
+
# Process.setsid # => 27422
|
1119
|
+
#
|
1120
|
+
# Not available on all platforms.
|
1121
|
+
#
|
1122
|
+
def self.setsid: () -> Integer
|
1123
|
+
|
1124
|
+
# <!--
|
1125
|
+
# rdoc-file=process.c
|
1126
|
+
# - Process.times -> process_tms
|
1127
|
+
# -->
|
1128
|
+
# Returns a Process::Tms structure that contains user and system CPU times for
|
1129
|
+
# the current process, and for its children processes:
|
1130
|
+
#
|
1131
|
+
# Process.times
|
1132
|
+
# # => #<struct Process::Tms utime=55.122118, stime=35.533068, cutime=0.0, cstime=0.002846>
|
1133
|
+
#
|
1134
|
+
# The precision is platform-defined.
|
1135
|
+
#
|
1136
|
+
def self.times: () -> Process::Tms
|
1137
|
+
|
1138
|
+
# <!--
|
1139
|
+
# rdoc-file=process.c
|
1140
|
+
# - Process.uid -> integer
|
1141
|
+
# - Process::UID.rid -> integer
|
1142
|
+
# - Process::Sys.getuid -> integer
|
1143
|
+
# -->
|
1144
|
+
# Returns the (real) user ID of the current process.
|
1145
|
+
#
|
1146
|
+
# Process.uid # => 1000
|
1147
|
+
#
|
1148
|
+
def self.uid: () -> Integer
|
1149
|
+
|
1150
|
+
# <!--
|
1151
|
+
# rdoc-file=process.c
|
1152
|
+
# - Process.uid = new_uid -> new_uid
|
1153
|
+
# -->
|
1154
|
+
# Sets the (user) user ID for the current process to `new_uid`:
|
1155
|
+
#
|
1156
|
+
# Process.uid = 1000 # => 1000
|
1157
|
+
#
|
1158
|
+
# Not available on all platforms.
|
1159
|
+
#
|
1160
|
+
def self.uid=: (Integer user) -> Integer
|
1161
|
+
|
1162
|
+
# <!--
|
1163
|
+
# rdoc-file=process.c
|
1164
|
+
# - Process.wait(pid = -1, flags = 0) -> integer
|
1165
|
+
# -->
|
1166
|
+
# Waits for a suitable child process to exit, returns its process ID, and sets
|
1167
|
+
# `$?` to a Process::Status object containing information on that process. Which
|
1168
|
+
# child it waits for depends on the value of the given `pid`:
|
1169
|
+
#
|
1170
|
+
# * Positive integer: Waits for the child process whose process ID is `pid`:
|
1171
|
+
#
|
1172
|
+
# pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 230866
|
1173
|
+
# pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 230891
|
1174
|
+
# Process.wait(pid0) # => 230866
|
1175
|
+
# $? # => #<Process::Status: pid 230866 exit 13>
|
1176
|
+
# Process.wait(pid1) # => 230891
|
1177
|
+
# $? # => #<Process::Status: pid 230891 exit 14>
|
1178
|
+
# Process.wait(pid0) # Raises Errno::ECHILD
|
1179
|
+
#
|
1180
|
+
# * `0`: Waits for any child process whose group ID is the same as that of the
|
1181
|
+
# current process:
|
1182
|
+
#
|
1183
|
+
# parent_pgpid = Process.getpgid(Process.pid)
|
1184
|
+
# puts "Parent process group ID is #{parent_pgpid}."
|
1185
|
+
# child0_pid = fork do
|
1186
|
+
# puts "Child 0 pid is #{Process.pid}"
|
1187
|
+
# child0_pgid = Process.getpgid(Process.pid)
|
1188
|
+
# puts "Child 0 process group ID is #{child0_pgid} (same as parent's)."
|
1189
|
+
# end
|
1190
|
+
# child1_pid = fork do
|
1191
|
+
# puts "Child 1 pid is #{Process.pid}"
|
1192
|
+
# Process.setpgid(0, Process.pid)
|
1193
|
+
# child1_pgid = Process.getpgid(Process.pid)
|
1194
|
+
# puts "Child 1 process group ID is #{child1_pgid} (different from parent's)."
|
1195
|
+
# end
|
1196
|
+
# retrieved_pid = Process.wait(0)
|
1197
|
+
# puts "Process.wait(0) returned pid #{retrieved_pid}, which is child 0 pid."
|
1198
|
+
# begin
|
1199
|
+
# Process.wait(0)
|
1200
|
+
# rescue Errno::ECHILD => x
|
1201
|
+
# puts "Raised #{x.class}, because child 1 process group ID differs from parent process group ID."
|
1202
|
+
# end
|
1203
|
+
#
|
1204
|
+
# Output:
|
1205
|
+
#
|
1206
|
+
# Parent process group ID is 225764.
|
1207
|
+
# Child 0 pid is 225788
|
1208
|
+
# Child 0 process group ID is 225764 (same as parent's).
|
1209
|
+
# Child 1 pid is 225789
|
1210
|
+
# Child 1 process group ID is 225789 (different from parent's).
|
1211
|
+
# Process.wait(0) returned pid 225788, which is child 0 pid.
|
1212
|
+
# Raised Errno::ECHILD, because child 1 process group ID differs from parent process group ID.
|
1213
|
+
#
|
1214
|
+
# * `-1` (default): Waits for any child process:
|
1215
|
+
#
|
1216
|
+
# parent_pgpid = Process.getpgid(Process.pid)
|
1217
|
+
# puts "Parent process group ID is #{parent_pgpid}."
|
1218
|
+
# child0_pid = fork do
|
1219
|
+
# puts "Child 0 pid is #{Process.pid}"
|
1220
|
+
# child0_pgid = Process.getpgid(Process.pid)
|
1221
|
+
# puts "Child 0 process group ID is #{child0_pgid} (same as parent's)."
|
1222
|
+
# end
|
1223
|
+
# child1_pid = fork do
|
1224
|
+
# puts "Child 1 pid is #{Process.pid}"
|
1225
|
+
# Process.setpgid(0, Process.pid)
|
1226
|
+
# child1_pgid = Process.getpgid(Process.pid)
|
1227
|
+
# puts "Child 1 process group ID is #{child1_pgid} (different from parent's)."
|
1228
|
+
# sleep 3 # To force child 1 to exit later than child 0 exit.
|
1229
|
+
# end
|
1230
|
+
# child_pids = [child0_pid, child1_pid]
|
1231
|
+
# retrieved_pid = Process.wait(-1)
|
1232
|
+
# puts child_pids.include?(retrieved_pid)
|
1233
|
+
# retrieved_pid = Process.wait(-1)
|
1234
|
+
# puts child_pids.include?(retrieved_pid)
|
1235
|
+
#
|
1236
|
+
# Output:
|
1237
|
+
#
|
1238
|
+
# Parent process group ID is 228736.
|
1239
|
+
# Child 0 pid is 228758
|
1240
|
+
# Child 0 process group ID is 228736 (same as parent's).
|
1241
|
+
# Child 1 pid is 228759
|
1242
|
+
# Child 1 process group ID is 228759 (different from parent's).
|
1243
|
+
# true
|
1244
|
+
# true
|
1245
|
+
#
|
1246
|
+
# * Less than `-1`: Waits for any child whose process group ID is `-pid`:
|
1247
|
+
#
|
1248
|
+
# parent_pgpid = Process.getpgid(Process.pid)
|
1249
|
+
# puts "Parent process group ID is #{parent_pgpid}."
|
1250
|
+
# child0_pid = fork do
|
1251
|
+
# puts "Child 0 pid is #{Process.pid}"
|
1252
|
+
# child0_pgid = Process.getpgid(Process.pid)
|
1253
|
+
# puts "Child 0 process group ID is #{child0_pgid} (same as parent's)."
|
1254
|
+
# end
|
1255
|
+
# child1_pid = fork do
|
1256
|
+
# puts "Child 1 pid is #{Process.pid}"
|
1257
|
+
# Process.setpgid(0, Process.pid)
|
1258
|
+
# child1_pgid = Process.getpgid(Process.pid)
|
1259
|
+
# puts "Child 1 process group ID is #{child1_pgid} (different from parent's)."
|
1260
|
+
# end
|
1261
|
+
# sleep 1
|
1262
|
+
# retrieved_pid = Process.wait(-child1_pid)
|
1263
|
+
# puts "Process.wait(-child1_pid) returned pid #{retrieved_pid}, which is child 1 pid."
|
1264
|
+
# begin
|
1265
|
+
# Process.wait(-child1_pid)
|
1266
|
+
# rescue Errno::ECHILD => x
|
1267
|
+
# puts "Raised #{x.class}, because there's no longer a child with process group id #{child1_pid}."
|
1268
|
+
# end
|
1269
|
+
#
|
1270
|
+
# Output:
|
1271
|
+
#
|
1272
|
+
# Parent process group ID is 230083.
|
1273
|
+
# Child 0 pid is 230108
|
1274
|
+
# Child 0 process group ID is 230083 (same as parent's).
|
1275
|
+
# Child 1 pid is 230109
|
1276
|
+
# Child 1 process group ID is 230109 (different from parent's).
|
1277
|
+
# Process.wait(-child1_pid) returned pid 230109, which is child 1 pid.
|
1278
|
+
# Raised Errno::ECHILD, because there's no longer a child with process group id 230109.
|
1279
|
+
#
|
1280
|
+
# Argument `flags` should be given as one of the following constants, or as the
|
1281
|
+
# logical OR of both:
|
1282
|
+
#
|
1283
|
+
# * Process::WNOHANG: Does not block if no child process is available.
|
1284
|
+
# * Process::WUNTRACED: May return a stopped child process, even if not yet
|
1285
|
+
# reported.
|
1286
|
+
#
|
1287
|
+
# Not all flags are available on all platforms.
|
1288
|
+
#
|
1289
|
+
# Raises Errno::ECHILD if there is no suitable child process.
|
1290
|
+
#
|
1291
|
+
# Not available on all platforms.
|
1292
|
+
#
|
1293
|
+
# Process.waitpid is an alias for Process.wait.
|
1294
|
+
#
|
1295
|
+
def self.wait: (?Integer pid, ?Integer flags) -> Integer
|
1296
|
+
|
1297
|
+
# <!--
|
1298
|
+
# rdoc-file=process.c
|
1299
|
+
# - Process.wait2(pid = -1, flags = 0) -> [pid, status]
|
1300
|
+
# -->
|
1301
|
+
# Like Process.waitpid, but returns an array containing the child process `pid`
|
1302
|
+
# and Process::Status `status`:
|
1303
|
+
#
|
1304
|
+
# pid = Process.spawn('ruby', '-e', 'exit 13') # => 309581
|
1305
|
+
# Process.wait2(pid)
|
1306
|
+
# # => [309581, #<Process::Status: pid 309581 exit 13>]
|
1307
|
+
#
|
1308
|
+
# Process.waitpid2 is an alias for Process.wait2.
|
1309
|
+
#
|
1310
|
+
def self.wait2: (?Integer pid, ?Integer flags) -> [ Integer, Process::Status ]
|
1311
|
+
|
1312
|
+
# <!--
|
1313
|
+
# rdoc-file=process.c
|
1314
|
+
# - Process.waitall -> array
|
1315
|
+
# -->
|
1316
|
+
# Waits for all children, returns an array of 2-element arrays; each subarray
|
1317
|
+
# contains the integer pid and Process::Status status for one of the reaped
|
1318
|
+
# child processes:
|
1319
|
+
#
|
1320
|
+
# pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 325470
|
1321
|
+
# pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 325495
|
1322
|
+
# Process.waitall
|
1323
|
+
# # => [[325470, #<Process::Status: pid 325470 exit 13>], [325495, #<Process::Status: pid 325495 exit 14>]]
|
1324
|
+
#
|
1325
|
+
def self.waitall: () -> ::Array[[ Integer, Process::Status ]]
|
1326
|
+
|
1327
|
+
# <!--
|
1328
|
+
# rdoc-file=process.c
|
1329
|
+
# - Process.wait(pid = -1, flags = 0) -> integer
|
1330
|
+
# -->
|
1331
|
+
# Waits for a suitable child process to exit, returns its process ID, and sets
|
1332
|
+
# `$?` to a Process::Status object containing information on that process. Which
|
1333
|
+
# child it waits for depends on the value of the given `pid`:
|
1334
|
+
#
|
1335
|
+
# * Positive integer: Waits for the child process whose process ID is `pid`:
|
1336
|
+
#
|
1337
|
+
# pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 230866
|
1338
|
+
# pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 230891
|
1339
|
+
# Process.wait(pid0) # => 230866
|
1340
|
+
# $? # => #<Process::Status: pid 230866 exit 13>
|
1341
|
+
# Process.wait(pid1) # => 230891
|
1342
|
+
# $? # => #<Process::Status: pid 230891 exit 14>
|
1343
|
+
# Process.wait(pid0) # Raises Errno::ECHILD
|
1344
|
+
#
|
1345
|
+
# * `0`: Waits for any child process whose group ID is the same as that of the
|
1346
|
+
# current process:
|
1347
|
+
#
|
1348
|
+
# parent_pgpid = Process.getpgid(Process.pid)
|
1349
|
+
# puts "Parent process group ID is #{parent_pgpid}."
|
1350
|
+
# child0_pid = fork do
|
1351
|
+
# puts "Child 0 pid is #{Process.pid}"
|
1352
|
+
# child0_pgid = Process.getpgid(Process.pid)
|
1353
|
+
# puts "Child 0 process group ID is #{child0_pgid} (same as parent's)."
|
1354
|
+
# end
|
1355
|
+
# child1_pid = fork do
|
1356
|
+
# puts "Child 1 pid is #{Process.pid}"
|
1357
|
+
# Process.setpgid(0, Process.pid)
|
1358
|
+
# child1_pgid = Process.getpgid(Process.pid)
|
1359
|
+
# puts "Child 1 process group ID is #{child1_pgid} (different from parent's)."
|
1360
|
+
# end
|
1361
|
+
# retrieved_pid = Process.wait(0)
|
1362
|
+
# puts "Process.wait(0) returned pid #{retrieved_pid}, which is child 0 pid."
|
1363
|
+
# begin
|
1364
|
+
# Process.wait(0)
|
1365
|
+
# rescue Errno::ECHILD => x
|
1366
|
+
# puts "Raised #{x.class}, because child 1 process group ID differs from parent process group ID."
|
1367
|
+
# end
|
1368
|
+
#
|
1369
|
+
# Output:
|
1370
|
+
#
|
1371
|
+
# Parent process group ID is 225764.
|
1372
|
+
# Child 0 pid is 225788
|
1373
|
+
# Child 0 process group ID is 225764 (same as parent's).
|
1374
|
+
# Child 1 pid is 225789
|
1375
|
+
# Child 1 process group ID is 225789 (different from parent's).
|
1376
|
+
# Process.wait(0) returned pid 225788, which is child 0 pid.
|
1377
|
+
# Raised Errno::ECHILD, because child 1 process group ID differs from parent process group ID.
|
1378
|
+
#
|
1379
|
+
# * `-1` (default): Waits for any child process:
|
1380
|
+
#
|
1381
|
+
# parent_pgpid = Process.getpgid(Process.pid)
|
1382
|
+
# puts "Parent process group ID is #{parent_pgpid}."
|
1383
|
+
# child0_pid = fork do
|
1384
|
+
# puts "Child 0 pid is #{Process.pid}"
|
1385
|
+
# child0_pgid = Process.getpgid(Process.pid)
|
1386
|
+
# puts "Child 0 process group ID is #{child0_pgid} (same as parent's)."
|
1387
|
+
# end
|
1388
|
+
# child1_pid = fork do
|
1389
|
+
# puts "Child 1 pid is #{Process.pid}"
|
1390
|
+
# Process.setpgid(0, Process.pid)
|
1391
|
+
# child1_pgid = Process.getpgid(Process.pid)
|
1392
|
+
# puts "Child 1 process group ID is #{child1_pgid} (different from parent's)."
|
1393
|
+
# sleep 3 # To force child 1 to exit later than child 0 exit.
|
1394
|
+
# end
|
1395
|
+
# child_pids = [child0_pid, child1_pid]
|
1396
|
+
# retrieved_pid = Process.wait(-1)
|
1397
|
+
# puts child_pids.include?(retrieved_pid)
|
1398
|
+
# retrieved_pid = Process.wait(-1)
|
1399
|
+
# puts child_pids.include?(retrieved_pid)
|
1400
|
+
#
|
1401
|
+
# Output:
|
1402
|
+
#
|
1403
|
+
# Parent process group ID is 228736.
|
1404
|
+
# Child 0 pid is 228758
|
1405
|
+
# Child 0 process group ID is 228736 (same as parent's).
|
1406
|
+
# Child 1 pid is 228759
|
1407
|
+
# Child 1 process group ID is 228759 (different from parent's).
|
1408
|
+
# true
|
1409
|
+
# true
|
1410
|
+
#
|
1411
|
+
# * Less than `-1`: Waits for any child whose process group ID is `-pid`:
|
1412
|
+
#
|
1413
|
+
# parent_pgpid = Process.getpgid(Process.pid)
|
1414
|
+
# puts "Parent process group ID is #{parent_pgpid}."
|
1415
|
+
# child0_pid = fork do
|
1416
|
+
# puts "Child 0 pid is #{Process.pid}"
|
1417
|
+
# child0_pgid = Process.getpgid(Process.pid)
|
1418
|
+
# puts "Child 0 process group ID is #{child0_pgid} (same as parent's)."
|
1419
|
+
# end
|
1420
|
+
# child1_pid = fork do
|
1421
|
+
# puts "Child 1 pid is #{Process.pid}"
|
1422
|
+
# Process.setpgid(0, Process.pid)
|
1423
|
+
# child1_pgid = Process.getpgid(Process.pid)
|
1424
|
+
# puts "Child 1 process group ID is #{child1_pgid} (different from parent's)."
|
1425
|
+
# end
|
1426
|
+
# sleep 1
|
1427
|
+
# retrieved_pid = Process.wait(-child1_pid)
|
1428
|
+
# puts "Process.wait(-child1_pid) returned pid #{retrieved_pid}, which is child 1 pid."
|
1429
|
+
# begin
|
1430
|
+
# Process.wait(-child1_pid)
|
1431
|
+
# rescue Errno::ECHILD => x
|
1432
|
+
# puts "Raised #{x.class}, because there's no longer a child with process group id #{child1_pid}."
|
1433
|
+
# end
|
1434
|
+
#
|
1435
|
+
# Output:
|
1436
|
+
#
|
1437
|
+
# Parent process group ID is 230083.
|
1438
|
+
# Child 0 pid is 230108
|
1439
|
+
# Child 0 process group ID is 230083 (same as parent's).
|
1440
|
+
# Child 1 pid is 230109
|
1441
|
+
# Child 1 process group ID is 230109 (different from parent's).
|
1442
|
+
# Process.wait(-child1_pid) returned pid 230109, which is child 1 pid.
|
1443
|
+
# Raised Errno::ECHILD, because there's no longer a child with process group id 230109.
|
1444
|
+
#
|
1445
|
+
# Argument `flags` should be given as one of the following constants, or as the
|
1446
|
+
# logical OR of both:
|
1447
|
+
#
|
1448
|
+
# * Process::WNOHANG: Does not block if no child process is available.
|
1449
|
+
# * Process::WUNTRACED: May return a stopped child process, even if not yet
|
1450
|
+
# reported.
|
1451
|
+
#
|
1452
|
+
# Not all flags are available on all platforms.
|
1453
|
+
#
|
1454
|
+
# Raises Errno::ECHILD if there is no suitable child process.
|
1455
|
+
#
|
1456
|
+
# Not available on all platforms.
|
1457
|
+
#
|
1458
|
+
# Process.waitpid is an alias for Process.wait.
|
1459
|
+
#
|
1460
|
+
def self.waitpid: (?Integer pid, ?Integer flags) -> Integer
|
1461
|
+
|
1462
|
+
# <!--
|
1463
|
+
# rdoc-file=process.c
|
1464
|
+
# - Process.wait2(pid = -1, flags = 0) -> [pid, status]
|
1465
|
+
# -->
|
1466
|
+
# Like Process.waitpid, but returns an array containing the child process `pid`
|
1467
|
+
# and Process::Status `status`:
|
1468
|
+
#
|
1469
|
+
# pid = Process.spawn('ruby', '-e', 'exit 13') # => 309581
|
1470
|
+
# Process.wait2(pid)
|
1471
|
+
# # => [309581, #<Process::Status: pid 309581 exit 13>]
|
1472
|
+
#
|
1473
|
+
# Process.waitpid2 is an alias for Process.wait2.
|
1474
|
+
#
|
1475
|
+
def self.waitpid2: (?Integer pid, ?Integer flags) -> [ Integer, Process::Status ]
|
1476
|
+
|
1477
|
+
# <!--
|
1478
|
+
# rdoc-file=process.c
|
1479
|
+
# - Process.warmup -> true
|
1480
|
+
# -->
|
1481
|
+
# Notify the Ruby virtual machine that the boot sequence is finished, and that
|
1482
|
+
# now is a good time to optimize the application. This is useful for long
|
1483
|
+
# running applications.
|
1484
|
+
#
|
1485
|
+
# 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, `Process.warmup` should
|
1487
|
+
# be called in the original process before the first fork.
|
1488
|
+
#
|
1489
|
+
# The actual optimizations performed are entirely implementation specific and
|
1490
|
+
# may change in the future without notice.
|
1491
|
+
#
|
1492
|
+
# On CRuby, `Process.warmup`:
|
1493
|
+
#
|
1494
|
+
# * Performs a major GC.
|
1495
|
+
# * Compacts the heap.
|
1496
|
+
# * Promotes all surviving objects to the old generation.
|
1497
|
+
# * Precomputes the coderange of all strings.
|
1498
|
+
# * Frees all empty heap pages and increments the allocatable pages counter by
|
1499
|
+
# the number of pages freed.
|
1500
|
+
# * Invoke `malloc_trim` if available to free empty malloc pages.
|
1501
|
+
#
|
1502
|
+
def self.warmup: () -> bool
|
1503
|
+
end
|
1504
|
+
|
1505
|
+
# <!-- rdoc-file=process.c -->
|
1506
|
+
# see Process.clock_gettime
|
1507
|
+
#
|
1508
|
+
Process::CLOCK_BOOTTIME: Integer
|
1509
|
+
|
1510
|
+
# <!-- rdoc-file=process.c -->
|
1511
|
+
# see Process.clock_gettime
|
1512
|
+
#
|
1513
|
+
Process::CLOCK_BOOTTIME_ALARM: Integer
|
1514
|
+
|
1515
|
+
# <!-- rdoc-file=process.c -->
|
1516
|
+
# see Process.clock_gettime
|
1517
|
+
#
|
1518
|
+
Process::CLOCK_MONOTONIC: Integer
|
1519
|
+
|
1520
|
+
# <!-- rdoc-file=process.c -->
|
1521
|
+
# see Process.clock_gettime
|
1522
|
+
#
|
1523
|
+
Process::CLOCK_MONOTONIC_COARSE: Integer
|
1524
|
+
|
1525
|
+
# <!-- rdoc-file=process.c -->
|
1526
|
+
# see Process.clock_gettime
|
1527
|
+
#
|
1528
|
+
Process::CLOCK_MONOTONIC_RAW: Integer
|
1529
|
+
|
1530
|
+
# <!-- rdoc-file=process.c -->
|
1531
|
+
# see Process.clock_gettime
|
1532
|
+
#
|
1533
|
+
Process::CLOCK_PROCESS_CPUTIME_ID: Integer
|
1534
|
+
|
1535
|
+
# <!-- rdoc-file=process.c -->
|
1536
|
+
# see Process.clock_gettime
|
1537
|
+
#
|
1538
|
+
Process::CLOCK_REALTIME: Integer
|
1539
|
+
|
1540
|
+
# <!-- rdoc-file=process.c -->
|
1541
|
+
# see Process.clock_gettime
|
1542
|
+
#
|
1543
|
+
Process::CLOCK_REALTIME_ALARM: Integer
|
1544
|
+
|
1545
|
+
# <!-- rdoc-file=process.c -->
|
1546
|
+
# see Process.clock_gettime
|
1547
|
+
#
|
1548
|
+
Process::CLOCK_REALTIME_COARSE: Integer
|
1549
|
+
|
1550
|
+
# <!-- rdoc-file=process.c -->
|
1551
|
+
# see Process.clock_gettime
|
1552
|
+
#
|
1553
|
+
Process::CLOCK_THREAD_CPUTIME_ID: Integer
|
1554
|
+
|
1555
|
+
# <!-- rdoc-file=process.c -->
|
1556
|
+
# see Process.setpriority
|
1557
|
+
#
|
1558
|
+
Process::PRIO_PGRP: Integer
|
1559
|
+
|
1560
|
+
# <!-- rdoc-file=process.c -->
|
1561
|
+
# see Process.setpriority
|
1562
|
+
#
|
1563
|
+
Process::PRIO_PROCESS: Integer
|
1564
|
+
|
1565
|
+
# <!-- rdoc-file=process.c -->
|
1566
|
+
# see Process.setpriority
|
1567
|
+
#
|
1568
|
+
Process::PRIO_USER: Integer
|
1569
|
+
|
1570
|
+
# <!-- rdoc-file=process.c -->
|
1571
|
+
# Maximum size of the process's virtual memory (address space) in bytes.
|
1572
|
+
#
|
1573
|
+
# see the system getrlimit(2) manual for details.
|
1574
|
+
#
|
1575
|
+
Process::RLIMIT_AS: Integer
|
1576
|
+
|
1577
|
+
# <!-- rdoc-file=process.c -->
|
1578
|
+
# Maximum size of the core file.
|
1579
|
+
#
|
1580
|
+
# see the system getrlimit(2) manual for details.
|
1581
|
+
#
|
1582
|
+
Process::RLIMIT_CORE: Integer
|
1583
|
+
|
1584
|
+
# <!-- rdoc-file=process.c -->
|
1585
|
+
# CPU time limit in seconds.
|
1586
|
+
#
|
1587
|
+
# see the system getrlimit(2) manual for details.
|
1588
|
+
#
|
1589
|
+
Process::RLIMIT_CPU: Integer
|
1590
|
+
|
1591
|
+
# <!-- rdoc-file=process.c -->
|
1592
|
+
# Maximum size of the process's data segment.
|
1593
|
+
#
|
1594
|
+
# see the system getrlimit(2) manual for details.
|
1595
|
+
#
|
1596
|
+
Process::RLIMIT_DATA: Integer
|
1597
|
+
|
1598
|
+
# <!-- rdoc-file=process.c -->
|
1599
|
+
# Maximum size of files that the process may create.
|
1600
|
+
#
|
1601
|
+
# see the system getrlimit(2) manual for details.
|
1602
|
+
#
|
1603
|
+
Process::RLIMIT_FSIZE: Integer
|
1604
|
+
|
1605
|
+
# <!-- rdoc-file=process.c -->
|
1606
|
+
# Maximum number of bytes of memory that may be locked into RAM.
|
1607
|
+
#
|
1608
|
+
# see the system getrlimit(2) manual for details.
|
1609
|
+
#
|
1610
|
+
Process::RLIMIT_MEMLOCK: Integer
|
1611
|
+
|
1612
|
+
# <!-- rdoc-file=process.c -->
|
1613
|
+
# Specifies the limit on the number of bytes that can be allocated for POSIX
|
1614
|
+
# message queues for the real user ID of the calling process.
|
1615
|
+
#
|
1616
|
+
# see the system getrlimit(2) manual for details.
|
1617
|
+
#
|
1618
|
+
Process::RLIMIT_MSGQUEUE: Integer
|
1619
|
+
|
1620
|
+
# <!-- rdoc-file=process.c -->
|
1621
|
+
# Specifies a ceiling to which the process's nice value can be raised.
|
1622
|
+
#
|
1623
|
+
# see the system getrlimit(2) manual for details.
|
1624
|
+
#
|
1625
|
+
Process::RLIMIT_NICE: Integer
|
1626
|
+
|
1627
|
+
# <!-- rdoc-file=process.c -->
|
1628
|
+
# Specifies a value one greater than the maximum file descriptor number that can
|
1629
|
+
# be opened by this process.
|
1630
|
+
#
|
1631
|
+
# see the system getrlimit(2) manual for details.
|
1632
|
+
#
|
1633
|
+
Process::RLIMIT_NOFILE: Integer
|
1634
|
+
|
1635
|
+
# <!-- rdoc-file=process.c -->
|
1636
|
+
# The maximum number of processes that can be created for the real user ID of
|
1637
|
+
# the calling process.
|
1638
|
+
#
|
1639
|
+
# see the system getrlimit(2) manual for details.
|
1640
|
+
#
|
1641
|
+
Process::RLIMIT_NPROC: Integer
|
1642
|
+
|
1643
|
+
# <!-- rdoc-file=process.c -->
|
1644
|
+
# The maximum number of pseudo-terminals that can be created for the real user
|
1645
|
+
# ID of the calling process.
|
1646
|
+
#
|
1647
|
+
# see the system getrlimit(2) manual for details.
|
1648
|
+
#
|
1649
|
+
Process::RLIMIT_NPTS: Integer
|
1650
|
+
|
1651
|
+
# <!-- rdoc-file=process.c -->
|
1652
|
+
# Specifies the limit (in pages) of the process's resident set.
|
1653
|
+
#
|
1654
|
+
# see the system getrlimit(2) manual for details.
|
1655
|
+
#
|
1656
|
+
Process::RLIMIT_RSS: Integer
|
1657
|
+
|
1658
|
+
# <!-- rdoc-file=process.c -->
|
1659
|
+
# Specifies a ceiling on the real-time priority that may be set for this
|
1660
|
+
# process.
|
1661
|
+
#
|
1662
|
+
# see the system getrlimit(2) manual for details.
|
1663
|
+
#
|
1664
|
+
Process::RLIMIT_RTPRIO: Integer
|
1665
|
+
|
1666
|
+
# <!-- rdoc-file=process.c -->
|
1667
|
+
# Specifies limit on CPU time this process scheduled under a real-time
|
1668
|
+
# scheduling policy can consume.
|
1669
|
+
#
|
1670
|
+
# see the system getrlimit(2) manual for details.
|
1671
|
+
#
|
1672
|
+
Process::RLIMIT_RTTIME: Integer
|
1673
|
+
|
1674
|
+
# <!-- rdoc-file=process.c -->
|
1675
|
+
# Specifies a limit on the number of signals that may be queued for the real
|
1676
|
+
# user ID of the calling process.
|
1677
|
+
#
|
1678
|
+
# see the system getrlimit(2) manual for details.
|
1679
|
+
#
|
1680
|
+
Process::RLIMIT_SIGPENDING: Integer
|
1681
|
+
|
1682
|
+
# <!-- rdoc-file=process.c -->
|
1683
|
+
# Maximum size of the stack, in bytes.
|
1684
|
+
#
|
1685
|
+
# see the system getrlimit(2) manual for details.
|
1686
|
+
#
|
1687
|
+
Process::RLIMIT_STACK: Integer
|
1688
|
+
|
1689
|
+
# <!-- rdoc-file=process.c -->
|
1690
|
+
# see Process.setrlimit
|
1691
|
+
#
|
1692
|
+
Process::RLIM_INFINITY: Integer
|
1693
|
+
|
1694
|
+
# <!-- rdoc-file=process.c -->
|
1695
|
+
# see Process.setrlimit
|
1696
|
+
#
|
1697
|
+
Process::RLIM_SAVED_CUR: Integer
|
1698
|
+
|
1699
|
+
# <!-- rdoc-file=process.c -->
|
1700
|
+
# see Process.setrlimit
|
1701
|
+
#
|
1702
|
+
Process::RLIM_SAVED_MAX: Integer
|
1703
|
+
|
1704
|
+
# <!-- rdoc-file=process.c -->
|
1705
|
+
# see Process.wait
|
1706
|
+
#
|
1707
|
+
Process::WNOHANG: Integer
|
1708
|
+
|
1709
|
+
# <!-- rdoc-file=process.c -->
|
1710
|
+
# see Process.wait
|
1711
|
+
#
|
1712
|
+
Process::WUNTRACED: Integer
|
1713
|
+
|
1714
|
+
# <!-- rdoc-file=process.c -->
|
1715
|
+
# The Process::GID module contains a collection of module functions which can be
|
1716
|
+
# used to portably get, set, and switch the current process's real, effective,
|
1717
|
+
# and saved group IDs.
|
1718
|
+
#
|
1719
|
+
module Process::GID
|
1720
|
+
# <!--
|
1721
|
+
# rdoc-file=process.c
|
1722
|
+
# - Process::GID.change_privilege(group) -> integer
|
1723
|
+
# -->
|
1724
|
+
# Change the current process's real and effective group ID to that specified by
|
1725
|
+
# *group*. Returns the new group ID. Not available on all platforms.
|
1726
|
+
#
|
1727
|
+
# [Process.gid, Process.egid] #=> [0, 0]
|
1728
|
+
# Process::GID.change_privilege(33) #=> 33
|
1729
|
+
# [Process.gid, Process.egid] #=> [33, 33]
|
1730
|
+
#
|
1731
|
+
def self.change_privilege: (Integer group) -> Integer
|
1732
|
+
|
1733
|
+
# <!--
|
1734
|
+
# rdoc-file=process.c
|
1735
|
+
# - Process.egid -> integer
|
1736
|
+
# - Process::GID.eid -> integer
|
1737
|
+
# - Process::Sys.geteid -> integer
|
1738
|
+
# -->
|
1739
|
+
# Returns the effective group ID for the current process:
|
1740
|
+
#
|
1741
|
+
# Process.egid # => 500
|
1742
|
+
#
|
1743
|
+
# Not available on all platforms.
|
1744
|
+
#
|
1745
|
+
def self.eid: () -> Integer
|
1746
|
+
|
1747
|
+
# <!--
|
1748
|
+
# rdoc-file=process.c
|
1749
|
+
# - Process::GID.from_name(name) -> gid
|
1750
|
+
# -->
|
1751
|
+
# Get the group ID by the *name*. If the group is not found, `ArgumentError`
|
1752
|
+
# will be raised.
|
1753
|
+
#
|
1754
|
+
# Process::GID.from_name("wheel") #=> 0
|
1755
|
+
# Process::GID.from_name("nosuchgroup") #=> can't find group for nosuchgroup (ArgumentError)
|
1756
|
+
#
|
1757
|
+
def self.from_name: (String name) -> Integer
|
1758
|
+
|
1759
|
+
# <!--
|
1760
|
+
# rdoc-file=process.c
|
1761
|
+
# - Process::GID.grant_privilege(group) -> integer
|
1762
|
+
# - Process::GID.eid = group -> integer
|
1763
|
+
# -->
|
1764
|
+
# Set the effective group ID, and if possible, the saved group ID of the process
|
1765
|
+
# to the given *group*. Returns the new effective group ID. Not available on all
|
1766
|
+
# platforms.
|
1767
|
+
#
|
1768
|
+
# [Process.gid, Process.egid] #=> [0, 0]
|
1769
|
+
# Process::GID.grant_privilege(31) #=> 33
|
1770
|
+
# [Process.gid, Process.egid] #=> [0, 33]
|
1771
|
+
#
|
1772
|
+
def self.grant_privilege: (Integer group) -> Integer
|
1773
|
+
|
1774
|
+
# <!--
|
1775
|
+
# rdoc-file=process.c
|
1776
|
+
# - Process::GID.re_exchange -> integer
|
1777
|
+
# -->
|
1778
|
+
# Exchange real and effective group IDs and return the new effective group ID.
|
1779
|
+
# Not available on all platforms.
|
1780
|
+
#
|
1781
|
+
# [Process.gid, Process.egid] #=> [0, 33]
|
1782
|
+
# Process::GID.re_exchange #=> 0
|
1783
|
+
# [Process.gid, Process.egid] #=> [33, 0]
|
1784
|
+
#
|
1785
|
+
def self.re_exchange: () -> Integer
|
1786
|
+
|
1787
|
+
# <!--
|
1788
|
+
# rdoc-file=process.c
|
1789
|
+
# - Process::GID.re_exchangeable? -> true or false
|
1790
|
+
# -->
|
1791
|
+
# Returns `true` if the real and effective group IDs of a process may be
|
1792
|
+
# exchanged on the current platform.
|
1793
|
+
#
|
1794
|
+
def self.re_exchangeable?: () -> bool
|
1795
|
+
|
1796
|
+
# <!--
|
1797
|
+
# rdoc-file=process.c
|
1798
|
+
# - Process.gid -> integer
|
1799
|
+
# - Process::GID.rid -> integer
|
1800
|
+
# - Process::Sys.getgid -> integer
|
1801
|
+
# -->
|
1802
|
+
# Returns the (real) group ID for the current process:
|
1803
|
+
#
|
1804
|
+
# Process.gid # => 1000
|
1805
|
+
#
|
1806
|
+
def self.rid: () -> Integer
|
1807
|
+
|
1808
|
+
# <!--
|
1809
|
+
# rdoc-file=process.c
|
1810
|
+
# - Process::GID.sid_available? -> true or false
|
1811
|
+
# -->
|
1812
|
+
# Returns `true` if the current platform has saved group ID functionality.
|
1813
|
+
#
|
1814
|
+
def self.sid_available?: () -> bool
|
1815
|
+
|
1816
|
+
# <!--
|
1817
|
+
# rdoc-file=process.c
|
1818
|
+
# - Process::GID.switch -> integer
|
1819
|
+
# - Process::GID.switch {|| block} -> object
|
1820
|
+
# -->
|
1821
|
+
# Switch the effective and real group IDs of the current process. If a *block*
|
1822
|
+
# is given, the group IDs will be switched back after the block is executed.
|
1823
|
+
# Returns the new effective group ID if called without a block, and the return
|
1824
|
+
# value of the block if one is given.
|
1825
|
+
#
|
1826
|
+
def self.switch: () -> Integer
|
1827
|
+
| [T] () { () -> T } -> T
|
1828
|
+
|
1829
|
+
def self.eid=: (Integer group) -> Integer
|
1830
|
+
end
|
1831
|
+
|
1832
|
+
# <!-- rdoc-file=process.c -->
|
1833
|
+
# A Process::Status contains information about a system process.
|
1834
|
+
#
|
1835
|
+
# Thread-local variable `$?` is initially `nil`. Some methods assign to it a
|
1836
|
+
# Process::Status object that represents a system process (either running or
|
1837
|
+
# terminated):
|
1838
|
+
#
|
1839
|
+
# `ruby -e "exit 99"`
|
1840
|
+
# stat = $? # => #<Process::Status: pid 1262862 exit 99>
|
1841
|
+
# stat.class # => Process::Status
|
1842
|
+
# stat.to_i # => 25344
|
1843
|
+
# stat.stopped? # => false
|
1844
|
+
# stat.exited? # => true
|
1845
|
+
# stat.exitstatus # => 99
|
1846
|
+
#
|
1847
|
+
class Process::Status < Object
|
1848
|
+
# <!--
|
1849
|
+
# rdoc-file=process.c
|
1850
|
+
# - stat & mask -> integer
|
1851
|
+
# -->
|
1852
|
+
# This method is deprecated as #to_i value is system-specific; use predicate
|
1853
|
+
# methods like #exited? or #stopped?, or getters like #exitstatus or #stopsig.
|
1854
|
+
#
|
1855
|
+
# Returns the logical AND of the value of #to_i with `mask`:
|
1856
|
+
#
|
1857
|
+
# `cat /nop`
|
1858
|
+
# stat = $? # => #<Process::Status: pid 1155508 exit 1>
|
1859
|
+
# sprintf('%x', stat.to_i) # => "100"
|
1860
|
+
# stat & 0x00 # => 0
|
1861
|
+
#
|
1862
|
+
# ArgumentError is raised if `mask` is negative.
|
1863
|
+
#
|
1864
|
+
def &: (Integer num) -> Integer
|
1865
|
+
|
1866
|
+
# <!--
|
1867
|
+
# rdoc-file=process.c
|
1868
|
+
# - stat == other -> true or false
|
1869
|
+
# -->
|
1870
|
+
# Returns whether the value of #to_i == `other`:
|
1871
|
+
#
|
1872
|
+
# `cat /nop`
|
1873
|
+
# stat = $? # => #<Process::Status: pid 1170366 exit 1>
|
1874
|
+
# sprintf('%x', stat.to_i) # => "100"
|
1875
|
+
# stat == 0x100 # => true
|
1876
|
+
#
|
1877
|
+
def ==: (untyped other) -> bool
|
1878
|
+
|
1879
|
+
# <!--
|
1880
|
+
# rdoc-file=process.c
|
1881
|
+
# - stat >> places -> integer
|
1882
|
+
# -->
|
1883
|
+
# This method is deprecated as #to_i value is system-specific; use predicate
|
1884
|
+
# methods like #exited? or #stopped?, or getters like #exitstatus or #stopsig.
|
1885
|
+
#
|
1886
|
+
# Returns the value of #to_i, shifted `places` to the right:
|
1887
|
+
#
|
1888
|
+
# `cat /nop`
|
1889
|
+
# stat = $? # => #<Process::Status: pid 1155508 exit 1>
|
1890
|
+
# stat.to_i # => 256
|
1891
|
+
# stat >> 1 # => 128
|
1892
|
+
# stat >> 2 # => 64
|
1893
|
+
#
|
1894
|
+
# ArgumentError is raised if `places` is negative.
|
1895
|
+
#
|
1896
|
+
def >>: (Integer num) -> Integer
|
1897
|
+
|
1898
|
+
# <!--
|
1899
|
+
# rdoc-file=process.c
|
1900
|
+
# - coredump? -> true or false
|
1901
|
+
# -->
|
1902
|
+
# Returns `true` if the process generated a coredump when it terminated, `false`
|
1903
|
+
# if not.
|
1904
|
+
#
|
1905
|
+
# Not available on all platforms.
|
1906
|
+
#
|
1907
|
+
def coredump?: () -> bool
|
1908
|
+
|
1909
|
+
# <!--
|
1910
|
+
# rdoc-file=process.c
|
1911
|
+
# - exited? -> true or false
|
1912
|
+
# -->
|
1913
|
+
# Returns `true` if the process exited normally (for example using an `exit()`
|
1914
|
+
# call or finishing the program), `false` if not.
|
1915
|
+
#
|
1916
|
+
def exited?: () -> bool
|
1917
|
+
|
1918
|
+
# <!--
|
1919
|
+
# rdoc-file=process.c
|
1920
|
+
# - exitstatus -> integer or nil
|
1921
|
+
# -->
|
1922
|
+
# Returns the least significant eight bits of the return code of the process if
|
1923
|
+
# it has exited; `nil` otherwise:
|
1924
|
+
#
|
1925
|
+
# `exit 99`
|
1926
|
+
# $?.exitstatus # => 99
|
1927
|
+
#
|
1928
|
+
def exitstatus: () -> Integer?
|
1929
|
+
|
1930
|
+
# <!--
|
1931
|
+
# rdoc-file=process.c
|
1932
|
+
# - inspect -> string
|
1933
|
+
# -->
|
1934
|
+
# Returns a string representation of `self`:
|
1935
|
+
#
|
1936
|
+
# system("false")
|
1937
|
+
# $?.inspect # => "#<Process::Status: pid 1303494 exit 1>"
|
1938
|
+
#
|
1939
|
+
def inspect: () -> String
|
1940
|
+
|
1941
|
+
# <!--
|
1942
|
+
# rdoc-file=process.c
|
1943
|
+
# - pid -> integer
|
1944
|
+
# -->
|
1945
|
+
# Returns the process ID of the process:
|
1946
|
+
#
|
1947
|
+
# system("false")
|
1948
|
+
# $?.pid # => 1247002
|
1949
|
+
#
|
1950
|
+
def pid: () -> Integer
|
1951
|
+
|
1952
|
+
# <!--
|
1953
|
+
# rdoc-file=process.c
|
1954
|
+
# - signaled? -> true or false
|
1955
|
+
# -->
|
1956
|
+
# Returns `true` if the process terminated because of an uncaught signal,
|
1957
|
+
# `false` otherwise.
|
1958
|
+
#
|
1959
|
+
def signaled?: () -> bool
|
1960
|
+
|
1961
|
+
# <!--
|
1962
|
+
# rdoc-file=process.c
|
1963
|
+
# - stopped? -> true or false
|
1964
|
+
# -->
|
1965
|
+
# Returns `true` if this process is stopped, and if the corresponding #wait call
|
1966
|
+
# had the Process::WUNTRACED flag set, `false` otherwise.
|
1967
|
+
#
|
1968
|
+
def stopped?: () -> bool
|
1969
|
+
|
1970
|
+
# <!--
|
1971
|
+
# rdoc-file=process.c
|
1972
|
+
# - stopsig -> integer or nil
|
1973
|
+
# -->
|
1974
|
+
# Returns the number of the signal that caused the process to stop, or `nil` if
|
1975
|
+
# the process is not stopped.
|
1976
|
+
#
|
1977
|
+
def stopsig: () -> Integer?
|
1978
|
+
|
1979
|
+
# <!--
|
1980
|
+
# rdoc-file=process.c
|
1981
|
+
# - success? -> true, false, or nil
|
1982
|
+
# -->
|
1983
|
+
# Returns:
|
1984
|
+
#
|
1985
|
+
# * `true` if the process has completed successfully and exited.
|
1986
|
+
# * `false` if the process has completed unsuccessfully and exited.
|
1987
|
+
# * `nil` if the process has not exited.
|
1988
|
+
#
|
1989
|
+
def success?: () -> bool
|
1990
|
+
|
1991
|
+
# <!--
|
1992
|
+
# rdoc-file=process.c
|
1993
|
+
# - termsig -> integer or nil
|
1994
|
+
# -->
|
1995
|
+
# Returns the number of the signal that caused the process to terminate or `nil`
|
1996
|
+
# if the process was not terminated by an uncaught signal.
|
1997
|
+
#
|
1998
|
+
def termsig: () -> Integer?
|
1999
|
+
|
2000
|
+
# <!--
|
2001
|
+
# rdoc-file=process.c
|
2002
|
+
# - to_i -> integer
|
2003
|
+
# -->
|
2004
|
+
# Returns the system-dependent integer status of `self`:
|
2005
|
+
#
|
2006
|
+
# `cat /nop`
|
2007
|
+
# $?.to_i # => 256
|
2008
|
+
#
|
2009
|
+
def to_i: () -> Integer
|
2010
|
+
|
2011
|
+
# <!--
|
2012
|
+
# rdoc-file=process.c
|
2013
|
+
# - to_s -> string
|
2014
|
+
# -->
|
2015
|
+
# Returns a string representation of `self`:
|
2016
|
+
#
|
2017
|
+
# `cat /nop`
|
2018
|
+
# $?.to_s # => "pid 1262141 exit 1"
|
2019
|
+
#
|
2020
|
+
def to_s: () -> String
|
2021
|
+
end
|
2022
|
+
|
2023
|
+
# <!-- rdoc-file=process.c -->
|
2024
|
+
# The Process::Sys module contains UID and GID functions which provide direct
|
2025
|
+
# bindings to the system calls of the same names instead of the more-portable
|
2026
|
+
# versions of the same functionality found in the Process, Process::UID, and
|
2027
|
+
# Process::GID modules.
|
2028
|
+
#
|
2029
|
+
module Process::Sys
|
2030
|
+
# <!--
|
2031
|
+
# rdoc-file=process.c
|
2032
|
+
# - Process.euid -> integer
|
2033
|
+
# - Process::UID.eid -> integer
|
2034
|
+
# - Process::Sys.geteuid -> integer
|
2035
|
+
# -->
|
2036
|
+
# Returns the effective user ID for the current process.
|
2037
|
+
#
|
2038
|
+
# Process.euid # => 501
|
2039
|
+
#
|
2040
|
+
def self.geteuid: () -> Integer
|
2041
|
+
|
2042
|
+
# <!--
|
2043
|
+
# rdoc-file=process.c
|
2044
|
+
# - Process.gid -> integer
|
2045
|
+
# - Process::GID.rid -> integer
|
2046
|
+
# - Process::Sys.getgid -> integer
|
2047
|
+
# -->
|
2048
|
+
# Returns the (real) group ID for the current process:
|
2049
|
+
#
|
2050
|
+
# Process.gid # => 1000
|
2051
|
+
#
|
2052
|
+
def self.getgid: () -> Integer
|
2053
|
+
|
2054
|
+
# <!--
|
2055
|
+
# rdoc-file=process.c
|
2056
|
+
# - Process.uid -> integer
|
2057
|
+
# - Process::UID.rid -> integer
|
2058
|
+
# - Process::Sys.getuid -> integer
|
2059
|
+
# -->
|
2060
|
+
# Returns the (real) user ID of the current process.
|
2061
|
+
#
|
2062
|
+
# Process.uid # => 1000
|
2063
|
+
#
|
2064
|
+
def self.getuid: () -> Integer
|
2065
|
+
|
2066
|
+
# <!--
|
2067
|
+
# rdoc-file=process.c
|
2068
|
+
# - Process::Sys.issetugid -> true or false
|
2069
|
+
# -->
|
2070
|
+
# Returns `true` if the process was created as a result of an execve(2) system
|
2071
|
+
# call which had either of the setuid or setgid bits set (and extra privileges
|
2072
|
+
# were given as a result) or if it has changed any of its real, effective or
|
2073
|
+
# saved user or group IDs since it began execution.
|
2074
|
+
#
|
2075
|
+
def self.issetugid: () -> bool
|
2076
|
+
|
2077
|
+
# <!--
|
2078
|
+
# rdoc-file=process.c
|
2079
|
+
# - Process::Sys.setegid(group) -> nil
|
2080
|
+
# -->
|
2081
|
+
# Set the effective group ID of the calling process to *group*. Not available
|
2082
|
+
# on all platforms.
|
2083
|
+
#
|
2084
|
+
def self.setegid: (Integer group) -> nil
|
2085
|
+
|
2086
|
+
# <!--
|
2087
|
+
# rdoc-file=process.c
|
2088
|
+
# - Process::Sys.seteuid(user) -> nil
|
2089
|
+
# -->
|
2090
|
+
# Set the effective user ID of the calling process to *user*. Not available on
|
2091
|
+
# all platforms.
|
2092
|
+
#
|
2093
|
+
def self.seteuid: (Integer user) -> nil
|
2094
|
+
|
2095
|
+
# <!--
|
2096
|
+
# rdoc-file=process.c
|
2097
|
+
# - Process::Sys.setgid(group) -> nil
|
2098
|
+
# -->
|
2099
|
+
# Set the group ID of the current process to *group*. Not available on all
|
2100
|
+
# platforms.
|
2101
|
+
#
|
2102
|
+
def self.setgid: (Integer group) -> nil
|
2103
|
+
|
2104
|
+
# <!--
|
2105
|
+
# rdoc-file=process.c
|
2106
|
+
# - Process::Sys.setregid(rid, eid) -> nil
|
2107
|
+
# -->
|
2108
|
+
# Sets the (group) real and/or effective group IDs of the current process to
|
2109
|
+
# *rid* and *eid*, respectively. A value of `-1` for either means to leave that
|
2110
|
+
# ID unchanged. Not available on all platforms.
|
2111
|
+
#
|
2112
|
+
def self.setregid: (Integer rid, Integer eid) -> nil
|
2113
|
+
|
2114
|
+
# <!--
|
2115
|
+
# rdoc-file=process.c
|
2116
|
+
# - Process::Sys.setresgid(rid, eid, sid) -> nil
|
2117
|
+
# -->
|
2118
|
+
# Sets the (group) real, effective, and saved user IDs of the current process to
|
2119
|
+
# *rid*, *eid*, and *sid* respectively. A value of `-1` for any value means to
|
2120
|
+
# leave that ID unchanged. Not available on all platforms.
|
2121
|
+
#
|
2122
|
+
def self.setresgid: (Integer rid, Integer eid, Integer sid) -> nil
|
2123
|
+
|
2124
|
+
# <!--
|
2125
|
+
# rdoc-file=process.c
|
2126
|
+
# - Process::Sys.setresuid(rid, eid, sid) -> nil
|
2127
|
+
# -->
|
2128
|
+
# Sets the (user) real, effective, and saved user IDs of the current process to
|
2129
|
+
# *rid*, *eid*, and *sid* respectively. A value of `-1` for any value means to
|
2130
|
+
# leave that ID unchanged. Not available on all platforms.
|
2131
|
+
#
|
2132
|
+
def self.setresuid: (Integer rid, Integer eid, Integer sid) -> nil
|
2133
|
+
|
2134
|
+
# <!--
|
2135
|
+
# rdoc-file=process.c
|
2136
|
+
# - Process::Sys.setreuid(rid, eid) -> nil
|
2137
|
+
# -->
|
2138
|
+
# Sets the (user) real and/or effective user IDs of the current process to *rid*
|
2139
|
+
# and *eid*, respectively. A value of `-1` for either means to leave that ID
|
2140
|
+
# unchanged. Not available on all platforms.
|
2141
|
+
#
|
2142
|
+
def self.setreuid: (Integer rid, Integer eid) -> nil
|
2143
|
+
|
2144
|
+
# <!--
|
2145
|
+
# rdoc-file=process.c
|
2146
|
+
# - Process::Sys.setrgid(group) -> nil
|
2147
|
+
# -->
|
2148
|
+
# Set the real group ID of the calling process to *group*. Not available on all
|
2149
|
+
# platforms.
|
2150
|
+
#
|
2151
|
+
def self.setrgid: (Integer group) -> nil
|
2152
|
+
|
2153
|
+
# <!--
|
2154
|
+
# rdoc-file=process.c
|
2155
|
+
# - Process::Sys.setruid(user) -> nil
|
2156
|
+
# -->
|
2157
|
+
# Set the real user ID of the calling process to *user*. Not available on all
|
2158
|
+
# platforms.
|
2159
|
+
#
|
2160
|
+
def self.setruid: (Integer user) -> nil
|
2161
|
+
|
2162
|
+
# <!--
|
2163
|
+
# rdoc-file=process.c
|
2164
|
+
# - Process::Sys.setuid(user) -> nil
|
2165
|
+
# -->
|
2166
|
+
# Set the user ID of the current process to *user*. Not available on all
|
2167
|
+
# platforms.
|
2168
|
+
#
|
2169
|
+
def self.setuid: (Integer user) -> nil
|
2170
|
+
end
|
2171
|
+
|
2172
|
+
# <!-- rdoc-file=process.c -->
|
2173
|
+
# The Process::UID module contains a collection of module functions which can be
|
2174
|
+
# used to portably get, set, and switch the current process's real, effective,
|
2175
|
+
# and saved user IDs.
|
2176
|
+
#
|
2177
|
+
module Process::UID
|
2178
|
+
# <!--
|
2179
|
+
# rdoc-file=process.c
|
2180
|
+
# - Process::UID.change_privilege(user) -> integer
|
2181
|
+
# -->
|
2182
|
+
# Change the current process's real and effective user ID to that specified by
|
2183
|
+
# *user*. Returns the new user ID. Not available on all platforms.
|
2184
|
+
#
|
2185
|
+
# [Process.uid, Process.euid] #=> [0, 0]
|
2186
|
+
# Process::UID.change_privilege(31) #=> 31
|
2187
|
+
# [Process.uid, Process.euid] #=> [31, 31]
|
2188
|
+
#
|
2189
|
+
def self.change_privilege: (Integer user) -> Integer
|
2190
|
+
|
2191
|
+
# <!--
|
2192
|
+
# rdoc-file=process.c
|
2193
|
+
# - Process.euid -> integer
|
2194
|
+
# - Process::UID.eid -> integer
|
2195
|
+
# - Process::Sys.geteuid -> integer
|
2196
|
+
# -->
|
2197
|
+
# Returns the effective user ID for the current process.
|
2198
|
+
#
|
2199
|
+
# Process.euid # => 501
|
2200
|
+
#
|
2201
|
+
def self.eid: () -> Integer
|
2202
|
+
|
2203
|
+
# <!--
|
2204
|
+
# rdoc-file=process.c
|
2205
|
+
# - Process::UID.from_name(name) -> uid
|
2206
|
+
# -->
|
2207
|
+
# Get the user ID by the *name*. If the user is not found, `ArgumentError` will
|
2208
|
+
# be raised.
|
2209
|
+
#
|
2210
|
+
# Process::UID.from_name("root") #=> 0
|
2211
|
+
# Process::UID.from_name("nosuchuser") #=> can't find user for nosuchuser (ArgumentError)
|
2212
|
+
#
|
2213
|
+
def self.from_name: (String name) -> Integer
|
2214
|
+
|
2215
|
+
# <!--
|
2216
|
+
# rdoc-file=process.c
|
2217
|
+
# - Process::UID.grant_privilege(user) -> integer
|
2218
|
+
# - Process::UID.eid= user -> integer
|
2219
|
+
# -->
|
2220
|
+
# Set the effective user ID, and if possible, the saved user ID of the process
|
2221
|
+
# to the given *user*. Returns the new effective user ID. Not available on all
|
2222
|
+
# platforms.
|
2223
|
+
#
|
2224
|
+
# [Process.uid, Process.euid] #=> [0, 0]
|
2225
|
+
# Process::UID.grant_privilege(31) #=> 31
|
2226
|
+
# [Process.uid, Process.euid] #=> [0, 31]
|
2227
|
+
#
|
2228
|
+
def self.grant_privilege: (Integer user) -> Integer
|
2229
|
+
|
2230
|
+
# <!--
|
2231
|
+
# rdoc-file=process.c
|
2232
|
+
# - Process::UID.re_exchange -> integer
|
2233
|
+
# -->
|
2234
|
+
# Exchange real and effective user IDs and return the new effective user ID. Not
|
2235
|
+
# available on all platforms.
|
2236
|
+
#
|
2237
|
+
# [Process.uid, Process.euid] #=> [0, 31]
|
2238
|
+
# Process::UID.re_exchange #=> 0
|
2239
|
+
# [Process.uid, Process.euid] #=> [31, 0]
|
2240
|
+
#
|
2241
|
+
def self.re_exchange: () -> Integer
|
2242
|
+
|
2243
|
+
# <!--
|
2244
|
+
# rdoc-file=process.c
|
2245
|
+
# - Process::UID.re_exchangeable? -> true or false
|
2246
|
+
# -->
|
2247
|
+
# Returns `true` if the real and effective user IDs of a process may be
|
2248
|
+
# exchanged on the current platform.
|
2249
|
+
#
|
2250
|
+
def self.re_exchangeable?: () -> bool
|
2251
|
+
|
2252
|
+
# <!--
|
2253
|
+
# rdoc-file=process.c
|
2254
|
+
# - Process.uid -> integer
|
2255
|
+
# - Process::UID.rid -> integer
|
2256
|
+
# - Process::Sys.getuid -> integer
|
2257
|
+
# -->
|
2258
|
+
# Returns the (real) user ID of the current process.
|
2259
|
+
#
|
2260
|
+
# Process.uid # => 1000
|
2261
|
+
#
|
2262
|
+
def self.rid: () -> Integer
|
2263
|
+
|
2264
|
+
# <!--
|
2265
|
+
# rdoc-file=process.c
|
2266
|
+
# - Process::UID.sid_available? -> true or false
|
2267
|
+
# -->
|
2268
|
+
# Returns `true` if the current platform has saved user ID functionality.
|
2269
|
+
#
|
2270
|
+
def self.sid_available?: () -> bool
|
2271
|
+
|
2272
|
+
# <!--
|
2273
|
+
# rdoc-file=process.c
|
2274
|
+
# - Process::UID.switch -> integer
|
2275
|
+
# - Process::UID.switch {|| block} -> object
|
2276
|
+
# -->
|
2277
|
+
# Switch the effective and real user IDs of the current process. If a *block* is
|
2278
|
+
# given, the user IDs will be switched back after the block is executed. Returns
|
2279
|
+
# the new effective user ID if called without a block, and the return value of
|
2280
|
+
# the block if one is given.
|
2281
|
+
#
|
2282
|
+
def self.switch: () -> Integer
|
2283
|
+
| [T] () { () -> T } -> T
|
2284
|
+
|
2285
|
+
def self.eid=: (Integer user) -> Integer
|
2286
|
+
end
|
2287
|
+
|
2288
|
+
# <!-- rdoc-file=process.c -->
|
2289
|
+
# Placeholder for rusage
|
2290
|
+
#
|
2291
|
+
class Process::Tms < Struct[Float]
|
2292
|
+
end
|
2293
|
+
|
2294
|
+
class Process::Waiter < Thread
|
2295
|
+
def pid: () -> Integer
|
2296
|
+
end
|