This is the development version of Kanrisuru. Since this is still a pre-1.0 release, we don't recommend using this in system-critical production environments.

Kanrisuru

Signal

The Kanrisuru::Util::Signal class is a lookup utility module that helps with translating and validating a signal from int to string representation. This lookup table currently supports linux signals.

Public Class Methods

[]

Lookup the opposing value of a signal. If the value is an integer, it will return a string; if the value is a string, it will return an integer.

Kanrisuru::Util::Signal['KILL']
9

Kanrisuru::Util::Signal[9]
'KILL'

valid?

Check if the signal exists in the lookup table.

Kanrisuru::Util::Signal.valid?('HUP')
true

Kanrisuru::Util::Signal.valid?(1)
true

Kanrisuru::Util::Signal.valid?('SIGHUP')
true

Kanrisuru::Util::Signal.valid?('')
false

Lookup Table

Has two lookup tables, @linux and @linux_inverted. Both created for quick in-memory lookup of signal translations.

Kanrisuru::Util::Signal.instance_variable_get(:@linux)
{
         "HUP" => 1,
         "INT" => 2,
        "QUIT" => 3,
         "ILL" => 4,
        "TRAP" => 5,
        "ABRT" => 6,
         "BUS" => 7,
         "FPE" => 8,
        "KILL" => 9,
        "USR1" => 10,
        "SEGV" => 11,
        "USR2" => 12,
        "PIPE" => 13,
        "ALRM" => 14,
        "TERM" => 15,
      "STKFLT" => 16,
        "CHLD" => 17,
        "CONT" => 18,
        "STOP" => 19,
        "TSTP" => 20,
        "TTIN" => 21,
        "TTOU" => 22,
         "URG" => 23,
        "XCPU" => 24,
        "XFSZ" => 25,
      "VTALRM" => 26,
        "PROF" => 27,
       "WINCH" => 28,
          "IO" => 29,
         "PWR" => 30,
         "SYS" => 31,
       "RTMIN" => 34,
     "RTMIN+1" => 35,
     "RTMIN+2" => 36,
     "RTMIN+3" => 37,
     "RTMIN+4" => 38,
     "RTMIN+5" => 39,
     "RTMIN+6" => 40,
     "RTMIN+7" => 41,
     "RTMIN+8" => 42,
     "RTMIN+9" => 43,
    "RTMIN+10" => 44,
    "RTMIN+11" => 45,
    "RTMIN+12" => 46,
    "RTMIN+13" => 47,
    "RTMIN+14" => 48,
    "RTMIN+15" => 49,
    "RTMAX-14" => 50,
    "RTMAX-13" => 51,
    "RTMAX-12" => 52,
    "RTMAX-11" => 53,
    "RTMAX-10" => 54,
     "RTMAX-9" => 55,
     "RTMAX-8" => 56,
     "RTMAX-7" => 57,
     "RTMAX-6" => 58,
     "RTMAX-5" => 59,
     "RTMAX-4" => 60,
     "RTMAX-3" => 61,
     "RTMAX-2" => 62,
     "RTMAX-1" => 63,
       "RTMAX" => 64
}


Kanrisuru::Util::Signal.instance_variable_get(:@linux_inverted)
{
     1 => "HUP",
     2 => "INT",
     3 => "QUIT",
     4 => "ILL",
     5 => "TRAP",
     6 => "ABRT",
     7 => "BUS",
     8 => "FPE",
     9 => "KILL",
    10 => "USR1",
    11 => "SEGV",
    12 => "USR2",
    13 => "PIPE",
    14 => "ALRM",
    15 => "TERM",
    16 => "STKFLT",
    17 => "CHLD",
    18 => "CONT",
    19 => "STOP",
    20 => "TSTP",
    21 => "TTIN",
    22 => "TTOU",
    23 => "URG",
    24 => "XCPU",
    25 => "XFSZ",
    26 => "VTALRM",
    27 => "PROF",
    28 => "WINCH",
    29 => "IO",
    30 => "PWR",
    31 => "SYS",
    34 => "RTMIN",
    35 => "RTMIN+1",
    36 => "RTMIN+2",
    37 => "RTMIN+3",
    38 => "RTMIN+4",
    39 => "RTMIN+5",
    40 => "RTMIN+6",
    41 => "RTMIN+7",
    42 => "RTMIN+8",
    43 => "RTMIN+9",
    44 => "RTMIN+10",
    45 => "RTMIN+11",
    46 => "RTMIN+12",
    47 => "RTMIN+13",
    48 => "RTMIN+14",
    49 => "RTMIN+15",
    50 => "RTMAX-14",
    51 => "RTMAX-13",
    52 => "RTMAX-12",
    53 => "RTMAX-11",
    54 => "RTMAX-10",
    55 => "RTMAX-9",
    56 => "RTMAX-8",
    57 => "RTMAX-7",
    58 => "RTMAX-6",
    59 => "RTMAX-5",
    60 => "RTMAX-4",
    61 => "RTMAX-3",
    62 => "RTMAX-2",
    63 => "RTMAX-1",
    64 => "RTMAX"
}