lib/hawatel_ps/linux/proc_table.rb
# Return attributes of searched process based on name or cmdline
#
# @example
#   search_by_name('java')
#   search_by_name('/^regex/')
#
# @param process_name[String] name of process
# @return [Array<ProcInfo>] array of ProcInfo objects
Return attributes of searched process based on name or cmdline
Return attributes of searched process based on name or cmdline
def search_by_name(process_name)
          refresh
          process_list = Array.new
          if process_name =~ /^\/.*\/$/
            process_name.slice!(0)
            process_name = Regexp.new(/#{process_name.chop}/)
          end
          @proc_table.each do |process|
           if process_name.is_a? Regexp
             process_list << process if process.name =~ process_name || process.cmdline =~ process_name
           else
             process_list << process if process.name == "#{process_name}" || process.cmdline == "#{process_name}"
           end
          end
          return process_list
        end
def search_by_name ( process_name ) refresh process_list = Array . new if process_name =~ / ^ \/ .* \/ $ / process_name . slice! ( 0 ) process_name = Regexp . new ( / #{ process_name . chop } / ) end @proc_table . each do | process | if process_name . is_a? Regexp process_list << process if process . name =~ process_name || process . cmdline =~ process_name else process_list << process if process . name == "#{process_name}" || process . cmdline == "#{process_name}" end end return process_list end
Return attributes of searched process based on name or cmdline
Return attributes of searched process based on name or cmdline
array of ProcInfo objects
array of ProcInfo objects
Array<ProcInfo>
process_name
name of process
name of process
example
None