1
require 'puppet/util/windows'
3
module Puppet::Util::Windows::Process
4
extend Windows::Process
6
extend Windows::Synchronize
8
def execute(command, arguments, stdin, stdout, stderr)
9
Process.create( :command_line => command, :startup_info => {:stdin => stdin, :stdout => stdout, :stderr => stderr}, :close_handles => false )
11
module_function :execute
13
def wait_process(handle)
14
while WaitForSingleObject(handle, 0) == Windows::Synchronize::WAIT_TIMEOUT
18
exit_status = [0].pack('L')
19
unless GetExitCodeProcess(handle, exit_status)
20
raise Puppet::Util::Windows::Error.new("Failed to get child process exit code")
22
exit_status = exit_status.unpack('L').first
24
# $CHILD_STATUS is not set when calling win32/process Process.create
25
# and since it's read-only, we can't set it. But we can execute a
26
# a shell that simply returns the desired exit status, which has the
28
%x{#{ENV['COMSPEC']} /c exit #{exit_status}}
32
module_function :wait_process