Method: Kernel#system
- Defined in:
- process.c
#system([env,][,options]) ⇒ true, ...
Executes command... in a subshell. command... is one of following forms.
commandline : command line string which is passed to the standard shell
cmdname, arg1, ... : command name and one or more arguments (no shell)
[cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
system returns true
if the command gives zero exit status, false
for non zero exit status. Returns nil
if command execution fails. An error status is available in $?
. The arguments are processed in the same way as for Kernel.spawn
.
The hash arguments, env and options, are same as exec
and spawn
. See Kernel.spawn
for details.
system("echo *")
system("echo", "*")
produces:
config.h main.rb
*
See Kernel.exec
for the standard shell.
|
# File 'process.c'
static VALUE
rb_f_system(int argc, VALUE *argv)
{
rb_pid_t pid;
int status;
#if defined(SIGCLD) && !defined(SIGCHLD)
# define SIGCHLD SIGCLD
#endif
#ifdef SIGCHLD
RETSIGTYPE (*chfunc)(int);
chfunc = signal(SIGCHLD, SIG_DFL);
#endif
pid = rb_spawn_internal(argc, argv, FALSE, NULL, 0);
#if defined(HAVE_FORK) || defined(HAVE_SPAWNV)
if (pid > 0) {
rb_syswait(pid);
}
|