Class: ChildProcess::Windows::Process::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/childprocess/windows/process.rb

Instance Method Summary collapse

Constructor Details

#initializeJob

Returns a new instance of Job.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/childprocess/windows/process.rb', line 96

def initialize
  @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

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

  ret = Lib.set_information_job_object(
    @pointer,
    JOB_OBJECT_EXTENDED_LIMIT_INFORMATION,
    extended,
    extended.size
  )

  Lib.check_error ret
end

Instance Method Details

#<<(handle) ⇒ Object



119
120
121
# File 'lib/childprocess/windows/process.rb', line 119

def <<(handle)
  Lib.check_error Lib.assign_process_to_job_object(@pointer, handle.pointer)
end

#closeObject



123
124
125
# File 'lib/childprocess/windows/process.rb', line 123

def close
  Lib.close_handle @pointer
end