(#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.