Module: ChildProcess::Windows

Defined in:
lib/childprocess/windows.rb,
lib/childprocess/windows/io.rb,
lib/childprocess/windows/api.rb,
lib/childprocess/windows/handle.rb,
lib/childprocess/windows/process.rb,
lib/childprocess/windows/structs.rb,
lib/childprocess/windows/constants.rb,
lib/childprocess/windows/functions.rb

Defined Under Namespace

Modules: Lib Classes: Handle, IO, Process, ProcessInfo, StartupInfo

Constant Summary collapse

FORMAT_MESSAGE_FROM_SYSTEM =
0x00001000
FORMAT_MESSAGE_ARGUMENT_ARRAY =
0x00002000
PROCESS_ALL_ACCESS =
0x1F0FFF
PROCESS_QUERY_INFORMATION =
0x0400
PROCESS_VM_READ =
0x0010
PROCESS_STILL_ACTIVE =
259
INFINITE =
0xFFFFFFFF
WIN_SIGINT =
2
WIN_SIGBREAK =
3
WIN_SIGKILL =
9
CTRL_C_EVENT =
0
CTRL_BREAK_EVENT =
1
DETACHED_PROCESS =
0x00000008
STARTF_USESTDHANDLES =
0x00000100
INVALID_HANDLE_VALUE =
0xFFFFFFFF
HANDLE_FLAG_INHERIT =
0x00000001

Class Method Summary collapse

Class Method Details

.dont_inherit(file) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/childprocess/windows/api.rb', line 31

def dont_inherit(file)
  unless file.respond_to?(:fileno)
    raise ArgumentError, "expected #{file.inspect} to respond to :fileno"
  end

  handle = Lib.get_os_file_handle(file.fileno)

  ok = Lib.set_handle_information(handle, HANDLE_FLAG_INHERIT, 0)
  ok or raise Error, Lib.last_error_message
end

.kill(signal, *pids) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/childprocess/windows/api.rb', line 4

def kill(signal, *pids)
  case signal
  when 'SIGINT', 'INT', :SIGINT, :INT
    signal = WIN_SIGINT
  when 'SIGBRK', 'BRK', :SIGBREAK, :BRK
    signal = WIN_SIGBREAK
  when 'SIGKILL', 'KILL', :SIGKILL, :KILL
    signal = WIN_SIGKILL
  when 0..9
    # Do nothing
  else
    raise Error, "invalid signal #{signal.inspect}"
  end

  pids.map { |pid| pid if send_signal(signal, pid) }.compact
end

.waitpid(pid, flags = 0) ⇒ Object



21
22
23
# File 'lib/childprocess/windows/api.rb', line 21

def waitpid(pid, flags = 0)
  wait_for_pid(pid, no_hang?(flags))
end

.waitpid2(pid, flags = 0) ⇒ Object



25
26
27
28
29
# File 'lib/childprocess/windows/api.rb', line 25

def waitpid2(pid, flags = 0)
  code = wait_for_pid(pid, no_hang?(flags))

  [pid, code] if code
end