| 208 | # Handle Ctrl+C and OMF's SIGTERM |
| 209 | Signal.trap("INT", stop) |
| 210 | Signal.trap("TERM", stop) |
| 211 | |
| 212 | begin |
| 213 | pingl2 |
| 214 | rescue EOFError |
| 215 | |
| 216 | end |
| 217 | end |
| 218 | |
| 219 | def stop() |
| 220 | return if @pingio.nil? |
| 221 | # Kill the ping process, which will result in EOFError from ping() |
| 222 | Process.kill("INT", @pingio.pid) |
| 223 | end |
| 224 | |
| 225 | end |
| 226 | begin |
| 227 | $stderr.puts "INFO\tpingl2 2.11.0\n" |
| 228 | app = Pingl2Wrapper.new(ARGV) |
| 229 | app.start() |
| 230 | sleep 1 |
| 231 | rescue Interrupt |
| 232 | rescue Exception => ex |
| 233 | $stderr.puts "Error\t#{ex}\n" |
| 234 | end |
| 235 | |
| 236 | |
| 237 | |
| 238 | # Local Variables: |
| 239 | # mode:ruby |
| 240 | # End: |
| 241 | # vim: ft=ruby:sw=2 |
| 242 | |