ProcessWatcher is a cross platform interface for running subprocesses safely. Unlike backticks or popen in Ruby 1.8, it will not invoke a shell. Unlike system, it will permits capturing the output. Unlike all native Ruby interfaces, it permits killing the subprocess if it consume too much space or takes too long. And it is easier to use on Windows than rolling it by hand.
require 'rubygems' require 'process_watcher' # Will raise ProcessWatcher::NonzeroExitCode if the exit code is not 0 output = ProcessWatcher.watch(command, [arguments]) # Will just run to completion and return the exit status output, status = ProcessWatcher.run(command, arg1, arg2, ...)
This gem can be installed by entering the following at the command prompt:
gem install process_watcher
Install the following RubyGems required for testing:
The build can be tested using the RSpec gem.
Copyright © 2010 RightScale, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.