nulayer/subexec — pull request #17 by brettg (2013-03-30 18:36:18+00:00)
Title: Prevent hanging when the spawned process fills the pipe buffer and no timeout is set.

I found that commands run w/o timeouts would hang if they produced enough output to fill the pipe buffer. The ruby pipe object fills up then stops reading until it gets read from, the spawned process never finishes while it waits for the pipe to accept more input, and so `Process.waitpid` waits indefinitely.

I figured the easiest fix is just to read from the pipe while waiting so this patch does that. `Process.waitpid` never gets called without the` Process::WNOHANG` flag and the output gets added to a string while waiting.

[Related Stack Overflow Discussion](http://stackoverflow.com/questions/13829830/ruby-process-spawn-stdout-pipe-buffer-size-limit)