Skip to content

Commit

Permalink
Merge 96b6b09 into 8e809fe
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophia Castellarin committed Jun 16, 2020
2 parents 8e809fe + 96b6b09 commit c0ae87e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/childprocess/windows/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def launch_process
@handle = Handle.open @pid

if leader?
@job = Job.new
@job = Job.new(detach?, true)
@job << @handle
end

Expand All @@ -93,15 +93,16 @@ def close_job_if_necessary


class Job
def initialize
def initialize(detach, leader)
@pointer = Lib.create_job_object(nil, nil)

if @pointer.nil? || @pointer.null?
raise Error, "unable to create job object"
end

basic = JobObjectBasicLimitInformation.new
basic[:LimitFlags] = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK
basic[:LimitFlags] |= JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if !detach
basic[:LimitFlags] |= JOB_OBJECT_LIMIT_BREAKAWAY_OK if leader

extended = JobObjectExtendedLimitInformation.new
extended[:BasicLimitInformation] = basic
Expand Down

0 comments on commit c0ae87e

Please sign in to comment.