Sha256: 2958186196780fc7b70bce0efd91177e141e3da4721d79a9d92891706ffd29e1

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require "java"

module ChildProcess
  module JRuby
    class Process < AbstractProcess

      def exited?
        return true if @exit_code

        assert_started
        @exit_code = @process.exitValue
      rescue java.lang.IllegalThreadStateException
        false
      end

      def stop
        assert_started

        @process.destroy
        @process.waitFor

        @exit_code = @process.exitValue
      end

      private

      def launch_process
        pb = java.lang.ProcessBuilder.new(@args)

        # not sure why this is necessary
        env = pb.environment
        ENV.each { |k,v| env.put(k, v) }

        @process = pb.start

        # Firefox 3.6 on Snow Leopard has a lot output on stderr, which makes
        # the launch act funny if we don't do something to the streams
        # Closing the streams solves the problem for now, but on other platforms
        # we might need to actually read them.

        @process.getErrorStream.close
        @process.getInputStream.close
      end

    end # Process
  end # JRuby
end # ChildProcess

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
childprocess-0.0.4 lib/childprocess/jruby/process.rb
childprocess-0.0.3 lib/childprocess/jruby/process.rb
childprocess-0.0.2 lib/childprocess/jruby/process.rb
childprocess-0.0.1 lib/childprocess/jruby/process.rb