Permalink
Browse files

un.rb: reduce duplication

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


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent a580c01 commit 7ed6c4eec87d0a9b11700acb0bd98c9f27e86119 @nobu nobu committed Aug 3, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/un.rb
View
10 lib/un.rb
@@ -317,11 +317,11 @@ def httpd
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

0 comments on commit 7ed6c4e

Please sign in to comment.