From 4a8688f544c4d96d865417a113ca285a7ba94ad1 Mon Sep 17 00:00:00 2001 From: Alan Pinstein Date: Sat, 7 Sep 2013 13:19:24 -0500 Subject: [PATCH] Fixes [gh-129] based on code review from eric. --- lib/god/conditions/process_exits.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/god/conditions/process_exits.rb b/lib/god/conditions/process_exits.rb index e018d497..afb8d8a6 100644 --- a/lib/god/conditions/process_exits.rb +++ b/lib/god/conditions/process_exits.rb @@ -28,7 +28,8 @@ def valid? end def pid - self.pid_file ? File.read(self.pid_file).strip.to_i : self.watch.pid + # only read pid once since lazy evaluation can cause bugs due to changing external state + @pid ||= self.pid_file ? File.read(self.pid_file).strip.to_i : self.watch.pid end def register @@ -50,6 +51,8 @@ def register def deregister pid = self.pid + @pid = nil # reset so that @pid will bootstrap itself again as needed + if pid EventHandler.deregister(pid, :proc_exit)