rbs 4.1.0.pre.2-java

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