lib/hawatel_ps/linux/proc_fetch.rb
# Get process uid and return username from passwd file
#
# @example
#  process_username(132)
#
# @param pid [Fixnum] process pid
# @return [String]
Get process uid and return username from passwd file
Get process uid and return username from passwd file
def process_username(pid)
          uid = File.stat("/proc/#{pid}").uid
          File.foreach('/etc/passwd').each do |line|
            if line.split(':')[2] == "#{uid}"
              return line.split(':')[0]
            end
          end
        end
def process_username ( pid ) uid = File . stat ( "/proc/#{pid}" ) . uid File . foreach ( '/etc/passwd' ) . each do | line | if line . split ( ':' ) [ 2 ] == "#{uid}" return line . split ( ':' ) [ 0 ] end end end
Get process uid and return username from passwd file
Get process uid and return username from passwd file
None
String
pid
None
example
None