# File lib/headless/cli_util.rb, line 49
    def self.kill_process(pid_filename, options={})
      if pid = 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

      unless options[:preserve_pid_file]
        begin
          FileUtils.rm pid_filename
        rescue Errno::ENOENT
          # pid file already removed
        end
      end
    end