Sha256: f7e54ec07759f515fd26c8603d73b23297d27afc782d40c04f2b685a00a4884b

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

module ChildProcess
  module Windows
    class Process < AbstractProcess
      #
      # @return [Fixnum] the pid of the process after it has started
      #
      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 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
        end

        exited
      end

      private

      def launch_process
        opts = {
          :inherit => false,
          :detach  => detach?,
          :duplex  => duplex?
        }

        if @io
          opts[:stdout] = @io.stdout
          opts[:stderr] = @io.stderr
        end

        # TODO: escape/quote arguments properly
        command = @args.join ' '

        @pid = Lib.create_proc(command, opts)
        @handle = Handle.open(@pid)

        if duplex?
          io._stdin = opts[:stdin]
        end

        self
      end

    end # Process
  end # Windows
end # ChildProcess

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/childprocess-0.1.7/lib/childprocess/windows/process.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/childprocess-0.1.7/lib/childprocess/windows/process.rb
childprocess-0.1.9 lib/childprocess/windows/process.rb
childprocess-0.1.8 lib/childprocess/windows/process.rb
childprocess-0.1.8.pre lib/childprocess/windows/process.rb
childprocess-0.1.7 lib/childprocess/windows/process.rb