[DOC] Rdoc for Process::Status (#8386)

This commit is contained in:
Burdette Lamar 2023-09-06 17:26:11 -05:00 committed by GitHub
parent acd626a583
commit 54274b8c65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2025-06-06 00:31:58 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>

View File

@ -859,8 +859,13 @@ pst_inspect(VALUE st)
* call-seq: * call-seq:
* stat == other -> true or false * stat == other -> true or false
* *
* Returns +true+ if the integer value of _stat_ * Returns whether the value of #to_i == +other+:
* equals <em>other</em>. *
* `cat /nop`
* stat = $? # => #<Process::Status: pid 1170366 exit 1>
* sprintf('%x', stat.to_i) # => "100"
* stat == 0x100 # => true
*
*/ */
static VALUE static VALUE
@ -873,14 +878,15 @@ pst_equal(VALUE st1, VALUE st2)
/* /*
* call-seq: * call-seq:
* stat & num -> integer * stat & mask -> integer
* *
* Logical AND of the bits in _stat_ with <em>num</em>. * Returns the logical AND of the value of #to_i with +mask+:
*
* `cat /nop`
* stat = $? # => #<Process::Status: pid 1155508 exit 1>
* sprintf('%x', stat.to_i) # => "100"
* stat & 0x00 # => 0
* *
* fork { exit 0x37 }
* Process.wait
* sprintf('%04x', $?.to_i) #=> "3700"
* sprintf('%04x', $? & 0x1e00) #=> "1600"
*/ */
static VALUE static VALUE
@ -894,14 +900,17 @@ pst_bitand(VALUE st1, VALUE st2)
/* /*
* call-seq: * call-seq:
* stat >> num -> integer * stat >> places -> integer
* *
* Shift the bits in _stat_ right <em>num</em> places. * Returns the value of #to_i, shifted +places+ to the right:
* *
* fork { exit 99 } #=> 26563 * `cat /nop`
* Process.wait #=> 26563 * stat = $? # => #<Process::Status: pid 1155508 exit 1>
* $?.to_i #=> 25344 * stat.to_i # => 256
* $? >> 8 #=> 99 * stat >> 1 # => 128
* stat >> 2 # => 64
*
* Returns zero if +places+ is negative.
*/ */
static VALUE static VALUE
@ -1157,44 +1166,30 @@ rb_process_status_wait(rb_pid_t pid, int flags)
* call-seq: * call-seq:
* Process::Status.wait(pid = -1, flags = 0) -> Process::Status * Process::Status.wait(pid = -1, flags = 0) -> Process::Status
* *
* Waits for a child process to exit and returns a Process::Status object * Like Process.wait, but returns a Process::Status object
* containing information on that process. Which child it waits on * (instead of an integer pid or nil);
* depends on the value of _pid_: * see Process.wait for the values of +pid+ and +flags+.
* *
* > 0:: Waits for the child whose process ID equals _pid_. * If there are child processes,
* waits for a child process to exit and returns a Process::Status object
* containing information on that process;
* sets thread-local variable <tt>$?</tt>:
* *
* 0:: Waits for any child whose process group ID equals that of the * Process.spawn('cat /nop') # => 1155880
* calling process. * Process::Status.wait # => #<Process::Status: pid 1155880 exit 1>
* $? # => #<Process::Status: pid 1155508 exit 1>
* *
* -1:: Waits for any child process (the default if no _pid_ is * If there is no child process,
* given). * returns an "empty" Process::Status object
* that does not represent an actual process;
* does not set thread-local variable <tt>$?</tt>:
* *
* < -1:: Waits for any child whose process group ID equals the absolute * Process::Status.wait # => #<Process::Status: pid -1 exit 0>
* value of _pid_. * $? # => #<Process::Status: pid 1155508 exit 1> # Unchanged.
* *
* The _flags_ argument may be a logical or of the flag values * May invoke the scheduler hook Fiber::Scheduler#process_wait.
* Process::WNOHANG (do not block if no child available)
* or Process::WUNTRACED (return stopped children that
* haven't been reported). Not all flags are available on all
* platforms, but a flag value of zero will work on all platforms.
* *
* Returns +nil+ if there are no child processes.
* Not available on all platforms. * Not available on all platforms.
*
* May invoke the scheduler hook _process_wait_.
*
* fork { exit 99 } #=> 27429
* Process::Status.wait #=> pid 27429 exit 99
* $? #=> nil
*
* pid = fork { sleep 3 } #=> 27440
* Time.now #=> 2008-03-08 19:56:16 +0900
* Process::Status.wait(pid, Process::WNOHANG) #=> nil
* Time.now #=> 2008-03-08 19:56:16 +0900
* Process::Status.wait(pid, 0) #=> pid 27440 exit 99
* Time.now #=> 2008-03-08 19:56:19 +0900
*
* This is an EXPERIMENTAL FEATURE.
*/ */
static VALUE static VALUE