This will always hit the timeout if the spawned process writes more than the output buffer size to either stdout or stderr, because at that point writes will block. On my mac the buffer size appears to be 65536, but I think seen it as low as 4k or 8k on linux boxes in the past.

To make it work even if there is a lot of output on both stdout and stderr you'll have to select on stdout and stderr and consume any data as it appears, instead of blocking until the process is finished.

I'd recommend to capture stderr as well and maybe raise if there is anything written to it. I've had to debug ruby code that spawns other processes, and it's a pain if the stderr of the other process is just silently discarded.

Anyway, those are my 2 cents, maybe for this use case this is good enough.