Why does the ps command iterate through all /proc/<PID>/ files even when Process ID (PID) is specified?

Solution Verified - Updated -

Issue

  • When running ps -fp <pid>, the ps process will stat and open all pid directories in /proc. The /proc filesystem is a memory-based filesystem used to provide a view into the process tree. The extra work to loop through every process is inefficient when the pid is being supplied as a command line argument.

Environment

  • Red Hat Enterprise Linux (RHEL) 5
  • Red Hat Enterprise Linux (RHEL) 6
  • Red Hat Enterprise Linux (RHEL) 7

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.