From eb619c04765ef31b0e88329cbfd138d24558776e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 1 Oct 2009 13:21:57 -0700 Subject: Avoid a small window when a pid file can be empty There's always been a small window of opportunity for a script to do File.read(pid).to_i would cause File.read() to read an empty file and return "". This closes that window while hopefully retaining backwards compatibility... We've always checked for dirname(pid) writability in Configurator, so we can safely write to a temporary file in the intended directory and then atomically rename() it to the destination path. --- test/exec/test_exec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb index e753c2d..268a84e 100644 --- a/test/exec/test_exec.rb +++ b/test/exec/test_exec.rb @@ -728,7 +728,7 @@ end } } sleep 1 # racy - daemon_pid = pid_file.read.to_i + daemon_pid = File.read(pid_file.path).to_i assert daemon_pid > 0 Process.kill(:HUP, daemon_pid) sleep 1 # racy -- cgit v1.2.3-24-ge0c7