Object
# File lib/headless/cli_util.rb, line 3 def self.application_exists?(app) `which #{app}`.strip != "" end
# File lib/headless/cli_util.rb, line 7 def self.ensure_application_exists!(app, error_message) if !self.application_exists?(app) raise Headless::Exception.new(error_message) end end
# File lib/headless/cli_util.rb, line 33 def self.fork_process(command, pid_filename, log_filename='/dev/null') pid = fork do STDERR.reopen(log_filename) exec command exit! 127 # safeguard in case exec fails end File.open pid_filename, 'w' do |f| f.puts pid end end
# File lib/headless/cli_util.rb, line 45 def self.kill_process(pid_filename, options={}) if pid = self.read_pid(pid_filename) begin Process.kill 'TERM', pid Process.wait pid if options[:wait] rescue Errno::ESRCH # no such process; assume it's already killed rescue Errno::ECHILD # Process.wait tried to wait on a dead process end end begin FileUtils.rm pid_filename rescue Errno::ENOENT # pid file already removed end end
Generated with the Darkfish Rdoc Generator 2.