8000 * process.c: Improve Process::exec documentation · plusplus/ruby@1d80ad6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1d80ad6

Browse files
author
zzak
committed
* process.c: Improve Process::exec documentation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 0544c09 commit 1d80ad6

File tree

2 files changed

+55
-35
lines changed

2 files changed

+55
-35
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Fri May 31 17:57:21 2013 Zachary Scott <zachary@zacharyscott.net>
2+
3+
* process.c: Improve Process::exec documentation
4+
15
Fri May 31 17:26:42 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
26

37
* vm_eval.c (rb_funcallv): add better names of rb_funcall2.

process.c

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,55 +2330,71 @@ static int rb_exec_without_timer_thread(const struct rb_execarg *eargp, char *er
23302330
* call-seq:
23312331
* exec([env,] command... [,options])
23322332
*
2333-
* Replaces the current process by running the given external _command_.
2334-
* _command..._ is one of following forms.
2333+
* Replaces the current process by running the given external _command_, which
2334+
* can take one of the following forms:
23352335
*
2336-
* commandline : command line string which is passed to the standard shell
2337-
* cmdname, arg1, ... : command name and one or more arguments (no shell)
2338-
* [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
2336+
* [<code>exec(commandline)</code>]
2337+
* command line string which is passed to the standard shell
2338+
* [<code>exec(cmdname, arg1, ...)</code>]
2339+
* command name and one or more arguments (no shell)
2340+
* [<code>exec([cmdname, argv0], arg1, ...)</code>]
2341+
* command name, argv[0] and zero or more arguments (no shell)
2342+
*
2343+
* In the first form, the string is taken as a command line that is subject to
2344+
* shell expansion before being executed.
2345+
*
2346+
* The standard shell always means <code>"/bin/sh"</code> on Unix-like systems,
2347+
* same as <code>ENV["RUBYSHELL"]</code>
2348+
* (or <code>ENV["COMSPEC"]</code> on Windows NT series), and similar.
2349+
*
2350+
* If the string from the first form (<code>exec("command")</code>) follows
2351+
* these simple rules:
23392352
*
2340-
* If single string is given as the command,
2341-
* it is taken as a command line that is subject to shell expansion before being executed.
2353+
* * no meta characters
2354+
* * no shell reserved word and no special built-in
2355+
* * Ruby invokes the command directly without shell
2356+
*
2357+
* You can force shell invocation by adding ";" to the string (because ";" is
2358+
* a meta character).
23422359
*
2343-
* The standard shell means always <code>"/bin/sh"</code> on Unix-like systems,
2344-
* <code>ENV["RUBYSHELL"]</code> or <code>ENV["COMSPEC"]</code> on Windows NT series, and
2345-
* similar.
2346-
* If _commandline_ is simple enough,
2347-
* no meta characters, no shell reserved word and no special built-in,
2348-
* Ruby invokes the command directly without shell.
2349-
* You can force shell invocation by adding ";" for _commandline_ (because ";" is a meta character).
23502360
* Note that this behavior is observable by pid obtained
2351-
* (return value of spawn() and IO#pid for IO.popen) is the pid of the invoked command, not shell.
2361+
* (return value of spawn() and IO#pid for IO.popen) is the pid of the invoked
2362+
* command, not shell.
23522363
*
2353-
* If two or more +string+ given,
2354-
* the first is taken as a command name and
2355-
* the rest are passed as parameters to command with no shell expansion.
2364+
* In the second form (<code>exec("command1", "arg1", ...)</code>), the first
2365+
* is taken as a command name and the rest are passed as parameters to command
2366+
* with no shell expansion.
23562367
*
2357-
* If a two-element array at the beginning of the command,
2358-
* the first element is the command to be executed,
2359-
* and the second argument is used as the <code>argv[0]</code> value,
2360-
* which may show up in process listings.
2368+
* In the third form (<code>exec(["command", "argv0"], "arg1", ...)</code>),
2369+
* starting a two-element array at the beginning of the command, the first
2370+
* element is the command to be executed, and the second argument is used as
2371+
* the <code>argv[0]</code> value, which may show up in process listings.
23612372
*
2362-
* In order to execute the command, one of the <code>exec(2)</code>
2363-
* system calls is used, so the running command may inherit some of the environment
2373+
* In order to execute the command, one of the <code>exec(2)</code> system
2374+
* calls are used, so the running command may inherit some of the environment
23642375
* of the original program (including open file descriptors).
2365-
* This behavior is modified by env and options.
2366-
* See <code>spawn</code> for details.
23672376
*
2368-
* Raises SystemCallError if the command couldn't execute (typically
2369-
* <code>Errno::ENOENT</code> when it was not found).
2377+
* This behavior is modified by the given +env+ and +options+ parameters. See
2378+
* ::spawn for details.
2379+
*
2380+
* If the command fails to execute (typically <code>Errno::ENOENT</code> when
2381+
* it was not found) a SystemCallError exception is raised.
2382+
*
2383+
* This method modifies process attributes according to given +options+ before
2384+
* <code>exec(2)</code> system call. See ::spawn for more details about the
2385+
* given +options+.
23702386
*
2371-
* This method modifies process attributes according to _options_
2372-
* (details described in <code>spawn</code>)
2373-
* before <code>exec(2)</code> system call.
2374-
* The modified attributes may be retained when <code>exec(2)</code> system call fails.
2375-
* For example, hard resource limits is not restorable.
2376-
* If it is not acceptable, consider to create a child process using <code>spawn</code> or <code>system</code>.
2387+
* The modified attributes may be retained when <code>exec(2)</code> system
2388+
* call fails.
2389+
*
2390+
* For example, hard resource limits are not restorable.
2391+
*
2392+
* Consider to create a child process using ::spawn or Kernel#system if this
2393+
* is not acceptable.
23772394
*
23782395
* exec "echo *" # echoes list of files in current directory
23792396
* # never get here
23802397
*
2381-
*
23822398
* exec "echo", "*" # echoes an asterisk
23832399
* # never get here
23842400
*/

0 commit comments

Comments
 (0)
0