Skip to content
class method

Open3.pipeline_start

Open3.pipeline_start([env, ] *cmds, options = {}) → [wait_threads]

Basically a wrapper for Process.spawn that:

  • Creates a child process for each of the given cmds by calling Process.spawn.

  • Does not wait for child processes to exit.

With no block given, returns an array of the wait threads for all of the child processes.

Example:

Example
wait_threads = Open3.pipeline_start('ls', 'grep R')
# => [#<Process::Waiter:0x000055e8de9d2bb0 run>, #<Process::Waiter:0x000055e8de9d2890 run>]
wait_threads.each do |wait_thread|
  wait_thread.join
end

Output:

Example
Rakefile
README.md

With a block given, calls the block with an array of the wait processes:

Example
Open3.pipeline_start('ls', 'grep R') do |wait_threads|
  wait_threads.each do |wait_thread|
    wait_thread.join
  end
end

Output:

Example
Rakefile
README.md

Like Process.spawn, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

If the first argument is a hash, it becomes leading argument env in each call to Process.spawn; see Execution Environment.

If the last argument is a hash, it becomes trailing argument options in each call to Process.spawn; see Execution Options.

Each remaining argument in cmds is one of:

  • A command_line: a string that begins with a shell reserved word or special built-in, or contains one or more metacharacters.

  • An exe_path: the string path to an executable to be called.

  • An array containing a command_line or an exe_path, along with zero or more string arguments for the command.

See Argument command_line or exe_path.