Commit becff20f authored by Seth Vargo's avatar Seth Vargo Committed by GitHub
Browse files

Merge pull request #142 from jeroenj/systemd-check

Fixes the systemd? check for pre Linux 2.6.33 kernels
parents ba19837f 15df350c
......@@ -25,7 +25,8 @@ class Chef
# @return [Boolean]
#
def systemd?(node)
IO.read('/proc/1/comm').chomp == 'systemd'
file = '/proc/1/comm'
File.exist?(file) && IO.read(file).chomp == 'systemd'
end
#
......
......@@ -22,13 +22,22 @@ describe Chef::Sugar::Init do
.and_return("systemd")
node = {}
expect(described_class.systemd?(node)).to be true
expect(described_class.systemd?(node)).to be true
end
it 'is false when /proc/1/comm is not systemd' do
node = {}
expect(described_class.systemd?(node)).to be false
end
it 'is false when /proc/1/comm does not exist' do
allow(File).to receive(:exist?)
.with("/proc/1/comm")
.and_return(false)
node = {}
expect(described_class.systemd?(node)).to be false
end
end
describe '#upstart?' do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment