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