Method: ChildProcess::Windows::Handle.open

Defined in:
lib/childprocess/windows/handle.rb

.open(pid, access = PROCESS_ALL_ACCESS) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/childprocess/windows/handle.rb', line 8

def open(pid, access = PROCESS_ALL_ACCESS)
  handle = Lib.open_process(access, false, pid)

  if handle.null?
    raise Error, Lib.last_error_message
  end

  h = new(handle, pid)
  return h unless block_given?

  begin
    yield h
  ensure
    h.close
  end
end