Fix bug: pid become zero when pid file is empty

This commit is contained in:
Koichi TANAKA 2014-12-03 16:47:02 +09:00
parent 7eddae31b7
commit 50b5fbed54
2 changed files with 3 additions and 2 deletions

View File

@ -55,6 +55,7 @@ class Fluentd
def pid
return unless File.exists?(pid_file)
return if File.zero?(pid_file)
File.read(pid_file).to_i rescue nil
end

View File

@ -20,10 +20,10 @@ describe 'Fluentd::Agent::LocalCommon' do
end
context 'valid pid file given' do
before { File.write pid_file_path, '99999' }
before { File.write pid_file_path, '9999' }
after { FileUtils.rm pid_file_path }
its(:pid) { should eq(99999) }
its(:pid) { should eq(9999) }
end
end
end