From 25d71d8ffe7b96e17d63d918bc7352c3c1e10eab Mon Sep 17 00:00:00 2001 From: Gregg Tanzillo Date: Sat, 1 Jul 2017 07:03:04 -0400 Subject: [PATCH] Merge pull request #15491 from jrafanie/do_not_remove_other_process_pidfile Only remove my process' pidfile. (cherry picked from commit 8dff3ce84db537aad522c580ce786c002a57548d) https://bugzilla.redhat.com/show_bug.cgi?id=1484485 --- lib/pid_file.rb | 2 +- spec/lib/pid_file_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pid_file.rb b/lib/pid_file.rb index 4c5269511e9..bc96f03d04c 100644 --- a/lib/pid_file.rb +++ b/lib/pid_file.rb @@ -21,7 +21,7 @@ def pid end def remove - FileUtils.rm(@fname) if File.file?(@fname) + FileUtils.rm(@fname) if pid == Process.pid end def create(remove_on_exit = true) diff --git a/spec/lib/pid_file_spec.rb b/spec/lib/pid_file_spec.rb index 4421dfb9b83..8f15db5054d 100644 --- a/spec/lib/pid_file_spec.rb +++ b/spec/lib/pid_file_spec.rb @@ -40,8 +40,8 @@ @pid_file.remove end - it "deletes when file does exist" do - allow(File).to receive(:file?).with(@fname).and_return(true) + it "deletes when file exist and is our process" do + allow(@pid_file).to receive(:pid).and_return(Process.pid) expect(FileUtils).to receive(:rm).with(@fname).once @pid_file.remove end