Sha256: 0809eb73a0c48855d7a430282693116ce976cca278ab921c3629bdf264f0e403

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

require 'commands/util'
require 'sys/proctable'

include Sys

module Commands

  def Commands.kill(options=nil)
    ProcTable.ps().find_all{|p| p.comm =~ /p4d/}.each do |p|
      begin
        Process.kill('TERM', p.pid)
      rescue
        puts "Problem killing #{p}, ignoring"
      end
    end

    is_running = true
    while is_running
      is_running = p4d_running?
      if is_running
        sleep 0.2
      end
    end
  end

  def Commands.print_kill_help
    puts <<-END.gsub(/^ {6}/,'')
      p4util kill

      Finds local p4d processes and kills them.

      On unix machines, will probably use `ps -x` and 'p4d', then will send
      SIGTERM signals to each process.
    END
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
p4util-0.1.1 ./lib/commands/kill.rb
p4util-0.1.0 ./lib/commands/kill.rb