[前][次][番号順一覧][スレッド一覧]

ruby-changes:24558

From: nobu <ko1@a...>
Date: Fri, 3 Aug 2012 17:23:28 +0900 (JST)
Subject: [ruby-changes:24558] nobu:r36609 (trunk): un.rb: reduce duplication

nobu	2012-08-03 17:23:18 +0900 (Fri, 03 Aug 2012)

  New Revision: 36609

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36609

  Log:
    un.rb: reduce duplication
    
    * lib/un.rb (httpd): reduce duplicated code.

  Modified files:
    trunk/lib/un.rb

Index: lib/un.rb
===================================================================
--- lib/un.rb	(revision 36608)
+++ lib/un.rb	(revision 36609)
@@ -317,11 +317,11 @@
     options[:DocumentRoot] = argv.shift
     s = WEBrick::HTTPServer.new(options)
     shut = proc {s.shutdown}
-    Signal.trap("TERM", shut)
-    Signal.trap("QUIT", shut) if Signal.list.has_key?("QUIT")
-    if STDIN.tty?
-      Signal.trap("HUP", shut) if Signal.list.has_key?("HUP")
-      Signal.trap("INT", shut)
+    siglist = %w"TERM QUIT"
+    siglist.concat(%w"HUP INT") if STDIN.tty?
+    siglist &= Signal.list.keys
+    siglist.each do |sig|
+      Signal.trap(sig, shut)
     end
     s.start
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]