Project

General

Profile

Feature #6236 ยป webrick.signal_exception.patch

Exit WEBrick on any SignalException, not just SIGINT - drbrain (Eric Hodel), 04/14/2012 07:50 AM

View differences:

lib/webrick/server.rb (working copy)
133 133
            rescue Errno::EBADF, IOError => ex
134 134
              # if the listening socket was closed in GenericServer#shutdown,
135 135
              # IO::select raise it.
136
            rescue Interrupt => ex # ^C
136
            rescue SignalException => ex
137 137
              @logger.fatal ex
138 138
              raise
139 139
            rescue Exception => ex
test/webrick/test_server.rb (working copy)
29 29
      :StopCallback => Proc.new{ stopped += 1 },
30 30
    }
31 31

  
32
    e = assert_raises(Interrupt) do
32
    e = assert_raises(SignalException) do
33 33
      TestWEBrick.start_server(Echo, config) { |server, addr, port, log|
34 34
        listener = server.listeners.first
35 35

  
36 36
        def listener.accept
37
          Process.kill(:INT, $$) # simulate ^C
37
          raise SignalException, 'SIGTERM' # simulate signal in main thread
38 38
        end
39 39

  
40 40
        Thread.pass while server.status != :Running