sstephenson/execjs — pull request #123 by rcook (2013-04-10 21:30:34+00:00)
Title: Update to ExternalRuntime to use Kernel.spawn version of IO.popen to merge stderr and stdout and enable timeouts

This fix changes exec_runtime to take an options hash that allows the caller to specify a :timeout option. This will impose a timeout on an exec or eval call. The with_timeout helper method imposes this timeout by running the external command on a separate thread if a non-zero and non-nil. Using the Kernel.spawn version of the IO.popen method 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. The exec and eval methods on Module and Runtime have been updated to take the new options hash. Note that this change does not implement timeouts for other runtimes. This will follow as I get to them.

REFERENCES

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