# File lib/daemons/pid.rb, line 6 def Pid.running?(pid, additional = nil) match_pid = Regexp.new("^\\s*#{pid}\\s") got_match = false ps_all = IO.popen("ps ax") # the correct syntax is without a dash (-) ! ps_all.each { |psline| next unless psline =~ match_pid got_match = true got_match = false if additional and psline !~ /#{additional}/ break } ps_all.close # an alternative would be to use the code below, but I don't know whether this is portable # `ps axo pid=`.split.include? pid.to_s return got_match end