Module: Flamingo::Daemon::TrapKeeper
- Included in:
- ChildProcess, Flamingod
- Defined in:
- lib/flamingo/daemon/trap_keeper.rb
Class Method Summary collapse
-
.trap(signal, &block) ⇒ Object
Use instead of Kernel.trap to ensure that only the process that originally registered the trap has its block executed.
Class Method Details
.trap(signal, &block) ⇒ Object
Use instead of Kernel.trap to ensure that only the process that originally registered the trap has its block executed. This is necessary for cases where we fork after setting up traps since the child process gets the traps from the parent.
9 10 11 12 13 14 15 16 |
# File 'lib/flamingo/daemon/trap_keeper.rb', line 9 def trap(signal,&block) owner_pid = Process.pid Kernel.trap(signal) do if Process.pid == owner_pid block.call end end end |