Class: Byebug::KillCommand

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



34
35
36
37
38
39
# File 'lib/byebug/commands/kill.rb', line 34

def description
  %{kill[ SIGNAL]

    Send [signal] to Process.pid
    Equivalent of Process.kill(Process.pid)}
end

.namesObject



30
31
32
# File 'lib/byebug/commands/kill.rb', line 30

def names
  %w(kill)
end

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/byebug/commands/kill.rb', line 9

def execute
  if @match[1]
    signame = @match[1]
    unless Signal.list.member?(signame)
      errmsg("signal name #{signame} is not a signal I know about\n")
      return false
    end
    if 'KILL' == signame
      @state.interface.close
    end
  else
    if not confirm("Really kill? (y/n) ")
      return
    else
      signame = 'KILL'
    end
  end
  Process.kill(signame, Process.pid)
end

#regexpObject



5
6
7
# File 'lib/byebug/commands/kill.rb', line 5

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