U:RDoc::AnyMethod[iI" exec:ETI"Kernel#exec;TF:publico:RDoc::Markup::Document:@parts[&o:RDoc::Markup::Paragraph; [I"QReplaces the current process by running the given external _command_, which ;TI")can take one of the following forms:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List:
@type:
LABEL:@items[o:RDoc::Markup::ListItem:@label[I"#exec(commandline)
;T; [o;
; [I">command line string which is passed to the standard shell;To;;[I"*exec(cmdname, arg1, ...)
;T; [o;
; [I"6command name and one or more arguments (no shell);To;;[I"3exec([cmdname, argv0], arg1, ...)
;T; [o;
; [I"@command name, argv[0] and zero or more arguments (no shell);T@o;
; [I"QIn the first form, the string is taken as a command line that is subject to ;TI"+shell expansion before being executed.;T@o;
; [I"RThe standard shell always means "/bin/sh"
on Unix-like systems, ;TI"+same as ENV["RUBYSHELL"]
;TI"H(or ENV["COMSPEC"]
on Windows NT series), and similar.;T@o;
; [I"NIf the string from the first form (exec("command")
) follows ;TI"these simple rules:;T@o;;
:BULLET;[o;;0; [o;
; [I"no meta characters;To;;0; [o;
; [I"3no shell reserved word and no special built-in;To;;0; [o;
; [I"4Ruby invokes the command directly without shell;T@o;
; [I"PYou can force shell invocation by adding ";" to the string (because ";" is ;TI"a meta character).;T@o;
; [I";Note that this behavior is observable by pid obtained ;TI"Q(return value of spawn() and IO#pid for IO.popen) is the pid of the invoked ;TI"command, not shell.;T@o;
; [I"PIn the second form (exec("command1", "arg1", ...)
), the first ;TI"Qis taken as a command name and the rest are passed as parameters to command ;TI"with no shell expansion.;T@o;
; [ I"OIn the third form (exec(["command", "argv0"], "arg1", ...)
), ;TI"Mstarting a two-element array at the beginning of the command, the first ;TI"Oelement is the command to be executed, and the second argument is used as ;TI"Kthe argv[0]
value, which may show up in process listings.;T@o;
; [I"MIn order to execute the command, one of the exec(2)
system ;TI"Pcalls are used, so the running command may inherit some of the environment ;TI"?of the original program (including open file descriptors).;T@o;
; [I"PThis behavior is modified by the given +env+ and +options+ parameters. See ;TI"::spawn for details.;T@o;
; [I"PIf the command fails to execute (typically Errno::ENOENT
when ;TI"=it was not found) a SystemCallError exception is raised.;T@o;
; [I"QThis method modifies process attributes according to given +options+ before ;TI"Nexec(2)
system call. See ::spawn for more details about the ;TI"given +options+.;T@o;
; [I"NThe modified attributes may be retained when exec(2)
system ;TI"call fails.;T@o;
; [I":For example, hard resource limits are not restorable.;T@o;
; [I"OConsider to create a child process using ::spawn or Kernel#system if this ;TI"is not acceptable.;T@o:RDoc::Markup::Verbatim; [
I"Eexec "echo *" # echoes list of files in current directory
;TI"# never get here
;TI"
;TI".exec "echo", "*" # echoes an asterisk
;TI"# never get here;T:@format0:
@fileI"process.c;T:0@omit_headings_from_table_of_contents_below0I"(exec([env,] command... [,options])
;T0[ I"(*args);T@}FI"Kernel;TcRDoc::NormalModule00