12 @@handler::EVENT_SYSTEM
18 when /darwin/i, /bsd/i
19 require 'god/event_handlers/kqueue_handler'
20 @@handler = KQueueHandler
22 require 'god/event_handlers/netlink_handler'
23 @@handler = NetlinkHandler
25 raise NotImplementedError, "Platform not supported for EventHandler"
29 require 'god/event_handlers/dummy_handler'
30 @@handler = DummyHandler
35 def self.register(pid, event, &block)
37 @@actions[pid][event] = block
38 @@handler.register_process(pid, @@actions[pid].keys)
41 def self.deregister(pid, event=nil)
45 @@handler.register_process(pid, []) if system("kill -0 #{pid} &> /dev/null")
47 @@actions[pid].delete(event)
48 @@handler.register_process(pid, @@actions[pid].keys) if system("kill -0 #{pid} &> /dev/null")
53 def self.call(pid, event, extra_data = {})
54 @@actions[pid][event].call(extra_data) if watching_pid?(pid) && @@actions[pid][event]
57 def self.watching_pid?(pid)
65 @@handler.handle_events
67 message = format("Unhandled exception (%s): %s\n%s",
68 e.class, e.message, e.backtrace.join("\n"))
69 applog(nil, :fatal, message)