lib/puppet/reports/wavefront.rb
# Walk up the process tree hierarchy, returning the name of the
# process above this one, and immediately below `init`, or
# equivalent. So, if the reporter is running as a cron job, it
# will return 'cron'.  If you run Puppet interactively, you'll
# likely get '/usr/lib/sshd'.
#
# It's a recursive function, which limits itself to ten
# iterations, to be on the safe side.
#
# @param pid [Integer] the process ID of the program for which we wish
#   to know the parent.
# @param depth [Integer] a counter recording the depth of recursion
# @raise [String] UnknownAncestor if it hits maximum recursion depth
# @return [String] the oldest ancestor of pid
#
Walk up the process tree hierarchy, returning the name of the
process above this one, and immediately below `init`, or
equivalent. So, if the reporter is running as a cron job, it
will return 'cron'.  If you run Puppet interactively, you'll
likely get '/usr/lib/sshd'.

It's a recursive function, which limits itself to ten
iterations, to be on the safe side.
Walk up the process tree hierarchy returning the name of the process above this one and immediately below ` init ` or equivalent . So if the reporter is running as a cron job it will return ' cron ' . If you run Puppet interactively you ' ll likely get ' / usr / lib / sshd ' . It ' s a recursive function which limits itself to ten iterations to be on the safe side .
def launched_from(pid, depth = 0)
  raise 'UnknownAncestor' if depth > 8
  cmd, ppid = ps_cmd(pid)
  return cmd if INIT_PID.include?(ppid.to_i)
  launched_from(ppid, depth + 1)
end
def launched_from ( pid , depth = 0 ) raise 'UnknownAncestor' if depth > 8 cmd , ppid = ps_cmd ( pid ) return cmd if INIT_PID . include? ( ppid . to_i ) launched_from ( ppid , depth + 1 ) end
Walk up the process tree hierarchy, returning the name of the
process above this one, and immediately below `init`, or
equivalent.
Walk up the process tree hierarchy returning the name of the process above this one and immediately below ` init ` or equivalent .
the oldest ancestor of pid
the oldest ancestor of pid
String
[String] UnknownAncestor if it hits maximum recursion depth
[ String ] UnknownAncestor if it hits maximum recursion depth
pid
the process ID of the program for which we wish to know the parent.
the process ID of the program for which we wish to know the parent .
depth
a counter recording the depth of recursion
a counter recording the depth of recursion