~ubuntu-branches/ubuntu/quantal/puppet/quantal

« back to all changes in this revision

Viewing changes to lib/puppet/util/windows/process.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-14 01:56:30 UTC
  • mfrom: (1.1.29) (3.1.43 sid)
  • Revision ID: package-import@ubuntu.com-20120714015630-ntj41rkvkq4zph4y
Tags: 2.7.18-1ubuntu1
* Resynchronise with Debian. (LP: #1023931) Remaining changes:
  - debian/puppetmaster-passenger.postinst: Make sure we error if puppet
    config print doesn't work
  - debian/puppetmaster-passenger.postinst: Ensure upgrades from
    <= 2.7.11-1 fixup passenger apache configuration.
* Dropped upstreamed patches:
  - debian/patches/CVE-2012-1906_CVE-2012-1986_to_CVE-2012-1989.patch
  - debian/patches/puppet-12844
  - debian/patches/2.7.17-Puppet-July-2012-CVE-fixes.patch
* Drop Build-Depends on ruby-rspec (in universe):
  - debian/control: remove ruby-rspec from Build-Depends
  - debian/patches/no-rspec.patch: make Rakefile work anyway if rspec
    isn't installed so we can use it in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'puppet/util/windows'
 
2
 
 
3
module Puppet::Util::Windows::Process
 
4
  extend Windows::Process
 
5
  extend Windows::Handle
 
6
  extend Windows::Synchronize
 
7
 
 
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 )
 
10
  end
 
11
  module_function :execute
 
12
 
 
13
  def wait_process(handle)
 
14
    while WaitForSingleObject(handle, 0) == Windows::Synchronize::WAIT_TIMEOUT
 
15
      sleep(1)
 
16
    end
 
17
 
 
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")
 
21
    end
 
22
    exit_status = exit_status.unpack('L').first
 
23
 
 
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
 
27
    # desired effect.
 
28
    %x{#{ENV['COMSPEC']} /c exit #{exit_status}}
 
29
 
 
30
    exit_status
 
31
  end
 
32
  module_function :wait_process
 
33
end