Class: Byebug::KillCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/kill.rb

Overview

Send custom signals to the debugged program.

Instance Attribute Summary

Attributes inherited from Command

#processor

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#arguments, columnize, #context, #frame, help, #initialize, match, to_s

Methods included from Helpers::StringHelper

#camelize, #deindent, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



16
17
18
19
20
21
22
23
24
# File 'lib/byebug/commands/kill.rb', line 16

def self.description
  <<-DESCRIPTION
    kill[ signal]

    #{short_description}

    Equivalent of Process.kill(Process.pid)
  DESCRIPTION
end

.regexpObject



12
13
14
# File 'lib/byebug/commands/kill.rb', line 12

def self.regexp
  /^\s* kill \s* (?:\s+(\S+))? \s*$/x
end

.short_descriptionObject



26
27
28
# File 'lib/byebug/commands/kill.rb', line 26

def self.short_description
  "Sends a signal to the current process"
end

Instance Method Details

#executeObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/byebug/commands/kill.rb', line 30

def execute
  if @match[1]
    signame = @match[1]

    return errmsg("signal name #{signame} is not a signal I know about\n") unless Signal.list.member?(signame)
  else
    return unless confirm("Really kill? (y/n) ")

    signame = "KILL"
  end

  processor.interface.close if signame == "KILL"
  Process.kill(signame, Process.pid)
end