puppetlabs/puppetlabs-reboot — pull request #23 by joshcooper (2014-02-03 23:21:15+00:00)
Title: (MODULES-447) Avoid ruby infinite loop when rebooting

Previously, we were using Open3.pipeline_w to spawn the watcher process,
which sets up an IO.pipe to pass arguments to the watcher process. On Windows,
this seems to trigger a ruby bug that causes a thread to go into an infinite
loop while shutting down the ruby process. Here is the call stack of the
native thread:

0028fc38 76d315e9 00000001 0028fc88 00000001 ntdll!NtWaitForMultipleObjects+0x15
0028fcd4 75b71a2c 0028fc88 0028fcfc 00000000 KERNELBASE!WaitForMultipleObjectsEx+0x100
0028fd1c 75b74220 00000001 7efde000 00000000 kernel32!WaitForMultipleObjectsExImplementation+0xe0
0028fd38 62e5f913 00000001 0028fe1c 00000000 kernel32!WaitForMultipleObjects+0x18
WARNING: Stack unwind information not available. Following frames may be wrong.
0028fda8 62e6288b 00000000 62e5e128 0062c668 msvcrt_ruby191!rb_mutex_unlock+0x152b
0028fe38 62d425d9 0062c78c 00000000 0028fec8 msvcrt_ruby191!rb_thread_terminate_all+0x187
0028fec8 62d42710 00000006 006223c8 0062235c msvcrt_ruby191!ruby_cleanup+0x2c1
0028fef8 0040136f 015ad9b8 00622b70 0028ff28 msvcrt_ruby191!ruby_run_node+0x50
0028ff28 004010b9 00000005 00622b70 006214e8 ruby+0x136f

I was able to reproduce this with a simple ruby program, not using puppet or
any windows specific gems.

This commit eliminates the use of pipeline_w (and IO.pipe) and just uses
spawn directly. This avoids triggering the ruby bug as far as I can tell.