Update to ExternalRuntime to use Kernel.spawn version of IO.popen to merge stderr and stdout and enable timeouts in Ruby 1.9 and later

This fix changes exec_runtime to take a timeout argument in order to impose a timeout on an exec or eval call. The with_timeout helper method implements this timeout behaviour by running the external command on a separate thread if non-zero and non-nil. Using the Kernel.spawn version of the IO.popen method (available in Ruby 1.9 and later) means that only a single child process needs to be spawned to handle merging of stderr and stdout: this allows exec_runtime to properly clean up the child process without leaving any orphans hanging around. Note that this change does not implement timeouts for other runtimes and works in Ruby 1.9 and later only.

    REFERENCES

http://unethicalblogger.com/2011/11/12/popen-can-suck-it.html