Sha256: 3207a406fde20a9dad2d678d458b29305674a41cc53e8fd414d9d1371bc0b908

Contents?: true

Size: 1.48 KB

Versions: 20

Compression:

Stored size: 1.48 KB

Contents

module ChildProcess
  module Windows
    class Process < AbstractProcess

      attr_reader :pid

      def io
        @io ||= Windows::IO.new
      end

      def stop(timeout = 3)
        assert_started

        # just kill right away on windows.
        log "sending KILL"
        @handle.send(WIN_SIGKILL)

        poll_for_exit(timeout)
      ensure
        @handle.close
      end

      def wait
        @handle.wait
        @exit_code = @handle.exit_code
        @handle.close

        @exit_code
      end

      def exited?
        return true if @exit_code
        assert_started

        code   = @handle.exit_code
        exited = code != PROCESS_STILL_ACTIVE

        log(:exited? => exited, :code => code)

        if exited
          @exit_code = code
          @handle.close
        end

        exited
      end

      private

      def launch_process
        builder = ProcessBuilder.new(@args)
        builder.inherit     = false
        builder.detach      = detach?
        builder.duplex      = duplex?
        builder.environment = @environment unless @environment.empty?
        builder.cwd         = @cwd

        if @io
          builder.stdout      = @io.stdout
          builder.stderr      = @io.stderr
        end

        @pid = builder.start
        @handle = Handle.open @pid

        if duplex?
          raise Error, "no stdin stream" unless builder.stdin
          io._stdin = builder.stdin
        end

        self
      end

    end # Process
  end # Windows
end # ChildProcess

Version data entries

20 entries across 20 versions & 7 rubygems

Version Path
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.9/lib/childprocess/windows/process.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.9/lib/childprocess/windows/process.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.9/lib/childprocess/windows/process.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.9/lib/childprocess/windows/process.rb
vagrant-shell-0.2.6 vendor/bundle/gems/childprocess-0.3.9/lib/childprocess/windows/process.rb
vagrant-shell-0.2.5 vendor/bundle/gems/childprocess-0.3.9/lib/childprocess/windows/process.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/childprocess-0.3.8/lib/childprocess/windows/process.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/childprocess-0.3.9/lib/childprocess/windows/process.rb
childprocess-0.3.9 lib/childprocess/windows/process.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/childprocess-0.3.8/lib/childprocess/windows/process.rb
childprocess-0.3.8 lib/childprocess/windows/process.rb
childprocess-0.3.7 lib/childprocess/windows/process.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.6/lib/childprocess/windows/process.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.6/lib/childprocess/windows/process.rb
childprocess-0.3.6 lib/childprocess/windows/process.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/childprocess-0.3.5/lib/childprocess/windows/process.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/childprocess-0.3.5/lib/childprocess/windows/process.rb
childprocess-0.3.5 lib/childprocess/windows/process.rb
childprocess-0.3.4 lib/childprocess/windows/process.rb
childprocess-0.3.3 lib/childprocess/windows/process.rb