Skip to content

Commit

Permalink
Merge pull request ManageIQ#15491 from jrafanie/do_not_remove_other_p…
Browse files Browse the repository at this point in the history
…rocess_pidfile

Only remove my process' pidfile.
  • Loading branch information
gtanzillo authored Jul 1, 2017
2 parents a13b67b + 9090b3e commit 8dff3ce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/pid_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pid_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8dff3ce

Please sign in to comment.