lib/heathen/executioner.rb
# Executes the given argument vector with ProcessBuilder.
# Returns the pid and exit status as Numeric, stdout and
# stderr as Strings.
#
Executes the given argument vector with ProcessBuilder.
Returns the pid and exit status as Numeric, stdout and
stderr as Strings.
Executes the given argument vector with ProcessBuilder . Returns the pid and exit status as Numeric stdout and stderr as Strings .
def _execute(*argv, options)
        builder = java.lang.ProcessBuilder.new
        builder.command(argv)
        if options[:dir]
          dir = java.io.File.new(options[:dir])
          builder.directory(dir)
        end
        process = builder.start()
        pid = if process.is_a?(Java::JavaLang::UNIXProcess)
          prop = process.get_class.get_declared_field('pid')
          prop.set_accessible true
          prop.get_int(process)
        end
        logger.info "[#{pid}] spawn '#{argv.join(' ')}'"
        stdout = process.get_input_stream.to_io
        stderr = process.get_error_stream.to_io
        if options[:binary]
          stdout.binmode
          stderr.binmode
        end
        wait_thr = Thread.new { process.wait_for; process.exit_value }
        out = Thread.new { stdout.read }.value
        err = Thread.new { stderr.read }.value
        [pid, wait_thr.value, out, err]
      end
def _execute ( * argv , options ) builder = java . lang . ProcessBuilder . new builder . command ( argv ) if options [ :dir ] dir = java . io . File . new ( options [ :dir ] ) builder . directory ( dir ) end process = builder . start ( ) pid = if process . is_a? ( Java :: JavaLang :: UNIXProcess ) prop = process . get_class . get_declared_field ( 'pid' ) prop . set_accessible true prop . get_int ( process ) end logger . info "[#{pid}] spawn '#{argv.join(' ')}'" stdout = process . get_input_stream . to_io stderr = process . get_error_stream . to_io if options [ :binary ] stdout . binmode stderr . binmode end wait_thr = Thread . new { process . wait_for ; process . exit_value } out = Thread . new { stdout . read } . value err = Thread . new { stderr . read } . value [ pid , wait_thr . value , out , err ] end
Executes the given argument vector with ProcessBuilder.
Executes the given argument vector with ProcessBuilder .
# Dirty hack, works on UNIX only.
argv
<not_specific>
options
<not_specific>