Class: Debugger::KillCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/ruby-debug/commands/kill.rb

Overview

Implements debugger “kill” command

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/ruby-debug/commands/kill.rb', line 41

def help(cmd)
  %{
    kill [SIGNAL]

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

.help_commandObject



37
38
39
# File 'lib/ruby-debug/commands/kill.rb', line 37

def help_command
  %w[kill]
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ruby-debug/commands/kill.rb', line 15

def execute
  puts @match[1]
  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.finalize
    end
  else
    if not confirm("Really kill? (y/n) ")
      return
    else 
      signame = 'KILL'
    end
  end
  Process.kill(signame, Process.pid)
end

#regexpObject



7
8
9
10
11
12
13
# File 'lib/ruby-debug/commands/kill.rb', line 7

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