Skip to content

Commit d80009d

Browse files
[DOC] RDoc for module Process (#8847)
1 parent f694bd1 commit d80009d

File tree

1 file changed

+61
-8
lines changed

1 file changed

+61
-8
lines changed

process.c

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8779,16 +8779,23 @@ proc_warmup(VALUE _)
87798779
*
87808780
* == \Process Creation
87818781
*
8782-
* Each of these methods creates a process:
8782+
* Each of the following methods executes a given command in a new process or subshell,
8783+
* or multiple commands in new processes and/or subshells.
8784+
* The choice of process or subshell depends on the form of the command;
8785+
* see {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
87838786
*
8784-
* - Process.exec: Replaces the current process by running a given external command.
8785-
* - Process.spawn, Kernel#spawn: Executes the given command and returns its pid without waiting for completion.
8786-
* - Kernel#system: Executes the given command in a subshell.
8787+
* - Process.spawn, Kernel#spawn: Executes the command;
8788+
* returns the new pid without waiting for completion.
8789+
* - Process.exec: Replaces the current process by executing the command.
87878790
*
8788-
* Each of these methods accepts:
8791+
* In addition:
87898792
*
8790-
* - An optional hash of environment variable names and values.
8791-
* - An optional hash of execution options.
8793+
* - \Method Kernel#system executes a given command-line (string) in a subshell;
8794+
* returns +true+, +false+, or +nil+.
8795+
* - \Method Kernel#` executes a given command-line (string) in a subshell;
8796+
* returns its $stdout string.
8797+
* - \Module Open3 supports creating child processes
8798+
* with access to their $stdin, $stdout, and $stderr streams.
87928799
*
87938800
* === Execution Environment
87948801
*
@@ -8801,7 +8808,6 @@ proc_warmup(VALUE _)
88018808
*
88028809
* Output:
88038810
*
8804-
* nil
88058811
* "0"
88068812
*
88078813
* The effect is usually similar to that of calling ENV#update with argument +env+,
@@ -8813,6 +8819,53 @@ proc_warmup(VALUE _)
88138819
* if the new process fails.
88148820
* For example, hard resource limits are not restored.
88158821
*
8822+
* === Argument +command_line+ or +exe_path+
8823+
*
8824+
* The required string argument is one of the following:
8825+
*
8826+
* - +command_line+ if it begins with a shell reserved word or special built-in,
8827+
* or if it contains one or more meta characters.
8828+
* - +exe_path+ otherwise.
8829+
*
8830+
* <b>Argument +command_line+</b>
8831+
*
8832+
* \String argument +command_line+ is a command line to be passed to a shell;
8833+
* it must begin with a shell reserved word, begin with a special built-in,
8834+
* or contain meta characters:
8835+
*
8836+
* system('if true; then echo "Foo"; fi') # => true # Shell reserved word.
8837+
* system('echo') # => true # Built-in.
8838+
* system('date > /tmp/date.tmp') # => true # Contains meta character.
8839+
* system('date > /nop/date.tmp') # => false
8840+
* system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
8841+
*
8842+
* The command line may also contain arguments and options for the command:
8843+
*
8844+
* system('echo "Foo"') # => true
8845+
*
8846+
* Output:
8847+
*
8848+
* Foo
8849+
*
8850+
* See {Execution Shell}[rdoc-ref:Process@Execution+Shell] for details about the shell.
8851+
*
8852+
* <b>Argument +exe_path+</b>
8853+
*
8854+
* Argument +exe_path+ is one of the following:
8855+
*
8856+
* - The string path to an executable to be called.
8857+
* - A 2-element array containing the path to an executable to be called,
8858+
* and the string to be used as the name of the executing process.
8859+
*
8860+
* Example:
8861+
*
8862+
* system('/usr/bin/date') # => true # Path to date on Unix-style system.
8863+
* system('foo') # => nil # Command failed.
8864+
*
8865+
* Output:
8866+
*
8867+
* Mon Aug 28 11:43:10 AM CDT 2023
8868+
*
88168869
* === Execution Options
88178870
*
88188871
* Optional trailing argument +options+ is a hash of execution options.

0 commit comments

Comments
 (0)