This repository has been archived by the owner on Jun 10, 2018. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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