HomePhorge

(#9636) Always set $CHILD_STATUS when executing on Windows
edc721e73766Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(#9636) Always set $CHILD_STATUS when executing on Windows

Previously, Puppet::Util.execute did not set $CHILD_STATUS on Windows,
including the Windows exec provider. This caused problems for the
'onlyif' and 'unless' exec parameters, among others.

When executing processes, the general approach on Unix, is to map
stdin, stdout, stderr of the child process to /dev/null or a file
descriptor, depending on the options specified, e.g. 'squelch',
'combine'. The use of a file, as opposed to creating a pipe, avoids
having to create reader threads, and the potential for deadlock that
can occur.

On Windows, we take the same approach. But this is complicated by the
lack of 'fork' and that $CHILD_STATUS is read-only. Ideally, we could
just use Process.spawn (as this allows redirection of stdin, etc), but
the method is only available in ruby 1.9.

So instead we use the win32/process gem, which uses the native Win32
API CreateProcess method. And the fix is to create a subprocess that
simply exits with the desired exit status, thereby setting
$CHILD_STATUS for us.

Also as part of this commit, the child_status variable was renamed to
exit_status, since that is what it is really, and to avoid confusion
with $CHILD_STATUS, which is something else entirely.

Details

Provenance
Josh Cooper <josh@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU448d5dbb675c: (#9636) Fix PATHEXT resolution for paths other than system32
Branches
Unknown
Tags
Unknown

Event Timeline

Josh Cooper <josh@puppetlabs.com> committed rPUedc721e73766: (#9636) Always set $CHILD_STATUS when executing on Windows (authored by Josh Cooper <josh@puppetlabs.com>).Oct 13 2011, 12:10 AM