thuehlinger / daemons

Ruby daemons gem official repository
MIT License
648 stars 71 forks source link

Using daemons to as described in section 3 of Basic Usage is broken since 70f69a71ce1f1e19e254203d6b8bcff5abc3796c #22

Closed robertoplancarte closed 9 years ago

robertoplancarte commented 9 years ago

The problem is that the @pid.pid in Deamons::Application is not getting updated when Daemonize.call_as_deamon is run because it is being set in the child process. You can see the problem by running the call examples (they run but leave processes running since Daemons.group.stop_all(true) wont find them without pids). This got broken by a commit which tried to avoid the race condition that happens when a parent process and child process try to update the same variable, but that would only happen if call_as_deamon ran a thread instead of a fork. Fortunately the function already handles interprocess communication using IO pipes, so we just need to revert the commit's changes to daemons/lib/daemons/application.rb to fix this.

sodabrew commented 9 years ago

Thanks for digging into this with a proposed fix!