Why does the ps command iterate through all /proc/<PID>/ files even when Process ID (PID) is specified?
Issue
- When running
ps -fp <pid>, thepsprocess will stat and open allpiddirectories in/proc. The/procfilesystem 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 thepidis 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, tools, and much more.