HomePhorge

(#11740) Wait on the handle from the PROCESS_INFORMATION structure
c5d382563e67Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(#11740) Wait on the handle from the PROCESS_INFORMATION structure

Previously, the Puppet::Util.execute method was using waitpid2 to
wait for the child process to exit and retrieve its exit status. On
Windows, this method (as implemented by the win32-process gem) opens a
handle to the process with the given pid, and then calls
WaitForSingleObject and GetExitCodeProcess on the process
handle. However, the pid-to-handle lookup will raise an exception if
the child process has exited. As a result there was a race condition
whereby puppet could sometimes fail to retrieve the exit status of
child processes.

The normal way of getting the exit code for a child process on Windows
is to use the child process handle contained in the
PROCESS_INFORMATION structure returned by CreateProcess. This
works regardless of whether the child process is currently executing
or not.

This commit reworks the Puppet::Util.execute_windows method to wait
on the child process handle contained in the process information
structure. This requires that we pass the :close_handles => false
option to the win32-process gem so that it doesn't close the handles.

This commit also re-enables tests that were previously being skipped
due to this bug.

Details

Provenance
Josh Cooper <josh@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU53380b98a289: Merge pull request #487 from joshcooper/ticket/2.7.x/12412-root-user
Branches
Unknown
Tags
Unknown

Event Timeline

Josh Cooper <josh@puppetlabs.com> committed rPUc5d382563e67: (#11740) Wait on the handle from the PROCESS_INFORMATION structure (authored by Josh Cooper <josh@puppetlabs.com>).Feb 21 2012, 1:31 AM