class Launchy::Detect::Runner::Forkable

Attributes

child_pid[R]

Public Instance Methods

wet_run( cmd, *args ) click to toggle source
# File lib/launchy/detect/runner.rb, line 119
def wet_run( cmd, *args )
  @child_pid = fork do
    close_file_descriptors unless Launchy.debug?
    Launchy.log("wet_run: before exec in child process")
    exec_or_raise( cmd, *args )
    exit!
  end
  Process.detach( @child_pid )
end

Private Instance Methods

close_file_descriptors() click to toggle source

attaching to a StringIO instead of reopening so we don’t loose the STDERR, needed for exec_or_raise.

# File lib/launchy/detect/runner.rb, line 133
def close_file_descriptors
  $stdin.reopen( "/dev/null")

  @saved_stdout = $stdout
  @saved_stderr = $stderr

  $stdout       = StringIO.new
  $stderr       = StringIO.new
end
exec_or_raise( cmd, *args ) click to toggle source
# File lib/launchy/detect/runner.rb, line 143
def exec_or_raise( cmd, *args )
  exec( *shell_commands( cmd, *args ))
rescue Exception => e
  $stderr = @saved_stderr
  $stdout = @saved_stdout
  raise e
end