Module: ProcessRunner

Defined in:
lib/process_runner.rb,
lib/process_runner/version.rb

Constant Summary collapse

VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.go(command, options = {}) ⇒ Integer

Starts an independent process asynchronously with the given command.

> (see IO#popen) for more information on available options.

Parameters:

  • command (Array)

    The command to run.

  • options (Hash) (defaults to: {})

    Options with which the process should be started.

Returns:

  • (Integer)

    The process ID of the started process.



11
12
13
14
15
# File 'lib/process_runner.rb', line 11

def self.go(command, options={})
  dirname = File.dirname(command.first)
  options.merge!(:chdir => dirname) if options[:chdir].nil? && dirname && !dirname.empty?
  Process.detach(Process.spawn(*command, options)).pid
end