# File examples/chatserver.rb, line 192 def pollLoop trap( "INT" ) { shutdown("Server caught SIGINT") } trap( "TERM" ) { shutdown("Server caught SIGTERM") } trap( "HUP" ) { disconnectAllUsers(">>> Server reset <<<") } until @shuttingDown eventCount = @pollObj.poll( @pollInterval ) $stderr.puts "#{eventCount} poll events..." if eventCount.nonzero? end rescue StandardError => e shutdown( "Server error: #{e.message}" ) rescue SignalException => e shutdown( "Server caught #{e.type.name}" ) ensure trap( "INT", "SIG_IGN" ) trap( "TERM", "SIG_IGN" ) trap( "HUP", "SIG_IGN" ) $stderr.puts "Server exiting poll loop." end