Sha256: f92376a973a91d0430da57c29a0648328cbb48af7c5adb49abf25c53425dbda7

Contents?: true

Size: 679 Bytes

Versions: 2

Compression:

Stored size: 679 Bytes

Contents

# Overrides process spawn for windows pgroup

require "async/process"

module Async
  module Process
    class Child
      def initialize(*args, **options)
        # Setup a cross-thread notification pipe - nio4r can't monitor pids unfortunately:
        pipe = ::IO.pipe
        @input = pipe.first
        @output = pipe.last

        @exit_status = nil

        if Gem.win_platform?
          options[:new_pgroup] = true
        else
          options[:pgroup] = true
        end

        @pid = ::Process.spawn(*args, **options)

        @thread = Thread.new do
          _, @exit_status = ::Process.wait2(@pid)
          @output.close
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sc2ai-0.3.0 lib/sc2ai/overrides/async/process/child.rb
sc2ai-0.2.0 lib/sc2ai/overrides/async/process/child.rb