From: "naruse (Yui NARUSE)" Date: 2012-04-14T11:21:29+09:00 Subject: [ruby-core:44356] [ruby-trunk - Feature #6236][Assigned] WEBrick::HTTPServer swallows Exception Issue #6236 has been updated by naruse (Yui NARUSE). Status changed from Closed to Assigned regularfry (Alex Young) wrote: > On 13/04/12 09:01, naruse (Yui NARUSE) wrote: > > > > Issue #6236 has been updated by naruse (Yui NARUSE). > > > > Status changed from Assigned to Closed > > > > This ticket looks intended to allow ^C shutting down the server. > > So current change to shutdown other than StandardError is too wide, it should be only Interrupt. > > You've reverted to catching non-StandardError Exceptions. Do you > disagree with my argument here? Oh sorry, I missed it and now I agree. I'll revert it. > Sending SIGINT to $$ raises an exception in the main thread (the test thread) not the WEBrick server thread which does not exercise the same code path. The test should exercise that WEBrick shuts down correctly upon ^C, not that assert_raises catches signal exceptions on the main thread and that the ensure in TestWEBrick#start_server works. I'll merge your patch. ---------------------------------------- Feature #6236: WEBrick::HTTPServer swallows Exception https://bugs.ruby-lang.org/issues/6236#change-25897 Author: regularfry (Alex Young) Status: Assigned Priority: Normal Assignee: nahi (Hiroshi Nakamura) Category: lib Target version: 2.0.0 At the moment when using WEBrick you've always got to remember to define a signal handler to be able to kill the server when you're done with it. This is annoying and makes it more painful to use than it should be, because if you realise you've forgotten to define a trap("INT") handler after you've started the server, all you can do is kill -9 the process. This also catches out people learning the library more than it should. It shouldn't be the web server's job to take over process management, but that's what it ends up doing. The reason this happens is because webrick/server.rb uses `rescue Exception` around its accept loop. This is more broad than it should be. The attached patch replaces this with a `rescue StandardError`, and causes other Exception subclasses to be logged and re-raised. This makes WEBrick::HTTPServer somewhat more friendly to use at the command-line. If you Ctrl-c out of a `server.start` loop with this patch applied, you can't restart the server because it leaves internal state lying around, but I think it's still an improvement over the current situation. -- http://bugs.ruby-lang.org/