PATH:
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Process
U:RDoc::AnyMethod[iI" spawn:ETI"Process::spawn;TT:publico:RDoc::Markup::Document:@parts[5o:RDoc::Markup::Paragraph; [I"?Creates a new child process by doing one of the following ;TI"in that process:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"0Passing string +command_line+ to the shell.;To;;0; [o; ; [I"+Invoking the executable at +exe_path+.;T@o; ; [I"XThis method has potential security vulnerabilities if called with untrusted input; ;TI">see {Command Injection}[rdoc-ref:command_injection.rdoc].;T@o; ; [I"6Returns the process ID (pid) of the new process, ;TI"(without waiting for it to complete.;T@o; ; [I"FTo avoid zombie processes, the parent process should call either:;T@o;; ;;[o;;0; [o; ; [I"GProcess.wait, to collect the termination statuses of its children.;To;;0; [o; ; [I"=Process.detach, to register disinterest in their status.;T@o; ; [ I"*The new process is created using the ;TI"m{exec system call}[https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/execve.html]; ;TI"Eit may inherit some of its environment from the calling program ;TI"0(possibly including open file descriptors).;T@o; ; [I"QArgument +env+, if given, is a hash that affects +ENV+ for the new process; ;TI"Isee {Execution Environment}[rdoc-ref:Process@Execution+Environment].;T@o; ; [I"BArgument +options+ is a hash of options for the new process; ;TI"Asee {Execution Options}[rdoc-ref:Process@Execution+Options].;T@o; ; [I"9The first required argument is one of the following:;T@o;; ;;[o;;0; [o; ; [I"'+command_line+ if it is a string, ;TI"Fand if it begins with a shell reserved word or special built-in, ;TI"3or if it contains one or more meta characters.;To;;0; [o; ; [I"+exe_path+ otherwise.;T@o; ; [I"#<b>Argument +command_line+</b>;T@o; ; [I"P\String argument +command_line+ is a command line to be passed to a shell; ;TI"Nit must begin with a shell reserved word, begin with a special built-in, ;TI" or contain meta characters:;T@o:RDoc::Markup::Verbatim; [ I"Nspawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word. ;TI"7Process.wait # => 798847 ;TI"Cspawn('exit') # => 798848 # Built-in. ;TI"7Process.wait # => 798848 ;TI"Rspawn('date > /tmp/date.tmp') # => 798879 # Contains meta character. ;TI"7Process.wait # => 798849 ;TI"Ospawn('date > /nop/date.tmp') # => 798882 # Issues error message. ;TI"7Process.wait # => 798882 ;T:@format0o; ; [I"MThe command line may also contain arguments and options for the command:;T@o;; [I"%spawn('echo "Foo"') # => 799031 ;TI"%Process.wait # => 799031 ;T;0o; ; [I"Output:;T@o;; [I" Foo ;T;0o; ; [I"YSee {Execution Shell}[rdoc-ref:Process@Execution+Shell] for details about the shell.;T@o; ; [I">Raises an exception if the new process could not execute.;T@o; ; [I"<b>Argument +exe_path+</b>;T@o; ; [I"1Argument +exe_path+ is one of the following:;T@o;; ;;[o;;0; [o; ; [I"3The string path to an executable to be called.;To;;0; [o; ; [I"JA 2-element array containing the path to an executable to be called, ;TI"Dand the string to be used as the name of the executing process.;T@o;; [I"Aspawn('/usr/bin/date') # Path to date on Unix-style system. ;TI"Process.wait ;T;0o; ; [I"Output:;T@o;; [I"%Mon Aug 28 11:43:10 AM CDT 2023 ;T;0o; ; [I"+Ruby invokes the executable directly. ;TI"'This form does not use the shell; ;TI"Gsee {Arguments args}[rdoc-ref:Process@Arguments+args] for caveats.;T@o; ; [I"CIf one or more +args+ is given, each is an argument or option ;TI"$to be passed to the executable:;T@o;; [ I"1spawn('echo', 'C*') # => 799392 ;TI"1Process.wait # => 799392 ;TI"1spawn('echo', 'hello', 'world') # => 799393 ;TI"1Process.wait # => 799393 ;T;0o; ; [I"Output:;T@o;; [I"C* ;TI"hello world ;T;0o; ; [I">Raises an exception if the new process could not execute.;T: @fileI"process.c;T:0@omit_headings_from_table_of_contents_below0I"kspawn([env, ] command_line, options = {}) -> pid spawn([env, ] exe_path, *args, options = {}) -> pid ;T0[ I"(*args);T@�FI"Process;TcRDoc::NormalModule00
[-] waitpid2-c.ri
[edit]
[-] wait-c.ri
[edit]
[-] abort-c.ri
[edit]
[-] exec-c.ri
[edit]
[-] clock_getres-c.ri
[edit]
[-] setpgid-c.ri
[edit]
[-] waitpid-c.ri
[edit]
[+]
Status
[-] cdesc-Process.ri
[edit]
[-] times-c.ri
[edit]
[-] getpriority-c.ri
[edit]
[-] last_status-c.ri
[edit]
[+]
GID
[-] wait2-c.ri
[edit]
[-] setpgrp-c.ri
[edit]
[-] detach-c.ri
[edit]
[-] argv0-c.ri
[edit]
[-] _fork-c.ri
[edit]
[-] uid%3d-c.ri
[edit]
[-] initgroups-c.ri
[edit]
[-] daemon-c.ri
[edit]
[+]
UID
[-] fork-c.ri
[edit]
[-] maxgroups-c.ri
[edit]
[-] groups-c.ri
[edit]
[-] groups%3d-c.ri
[edit]
[-] kill-c.ri
[edit]
[-] getpgid-c.ri
[edit]
[-] gid%3d-c.ri
[edit]
[-] maxgroups%3d-c.ri
[edit]
[-] setproctitle-c.ri
[edit]
[-] getpgrp-c.ri
[edit]
[-] ppid-c.ri
[edit]
[-] getsid-c.ri
[edit]
[+]
Sys
[-] egid-c.ri
[edit]
[-] setrlimit-c.ri
[edit]
[-] egid%3d-c.ri
[edit]
[-] clock_gettime-c.ri
[edit]
[+]
Tms
[+]
..
[-] exit%21-c.ri
[edit]
[-] gid-c.ri
[edit]
[-] setpriority-c.ri
[edit]
[-] spawn-c.ri
[edit]
[-] euid-c.ri
[edit]
[-] getrlimit-c.ri
[edit]
[-] setsid-c.ri
[edit]
[-] waitall-c.ri
[edit]
[-] uid-c.ri
[edit]
[-] exit-c.ri
[edit]
[-] warmup-c.ri
[edit]
[-] pid-c.ri
[edit]
[-] euid%3d-c.ri
[edit]