Skip to content

Commit

Permalink
resource/launchd_service: correctly match non-running services
Browse files Browse the repository at this point in the history
  • Loading branch information
srenatus committed Jan 22, 2016
1 parent 2dc5929 commit 6a81339
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/resources/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,15 @@ def info(service_name)
return nil if srv.nil? || srv[0].nil?

# extract values from service
parsed_srv = /^([0-9]+)\s*(\w*)\s*(\S*)/.match(srv[0])
enabled = !parsed_srv.nil?
parsed_srv = /^(?<pid>[0-9-]+)\t(?<exit>[0-9]+)\t(?<name>\S*)$/.match(srv[0])
enabled = !parsed_srv['name'].nil? # it's in the list

# check if the service is running
pid = parsed_srv[0]
running = !pid.nil?
pid = parsed_srv['pid']
running = pid != '-'

# extract service label
srv = parsed_srv[3] || service_name
srv = parsed_srv['name'] || service_name

{
name: srv,
Expand Down

0 comments on commit 6a81339

Please sign in to comment.