SignalException

SignalException

SignalException은 프로세스가 시그널(signal)을 받았을 때 던져지는 예외예요. Exception을 상속받아요.

출처: Ruby 3.3 API

본문

예를 들어 Process.kill('HUP', Process.pid)로 자기 자신에게 HUP 시그널을 보내면, 기본 동작 대신 rescue로 이 예외를 잡아 처리할 수 있어요.

begin
  Process.kill('HUP', Process.pid)
  sleep # wait for receiver to handle signal sent by Process.kill
rescue SignalException => e
  puts "received Exception #{e}"
end

실행 결과는 다음과 같아요.

received Exception SIGHUP

Public Class Methods

new(sig_name)              →  signal_exception
new(sig_number [, name])   →  signal_exception

새로운 SignalException 객체를 만들어요. sig_name은 알려진 시그널 이름이어야 해요.

Public Instance Methods

signo → num

시그널 번호를 돌려줘요.

e.signo