Background: I'm playing around with monitoring the ulimit for running processes for a particular user. (I had occasionally seen processes that were getting started with an incorrect limit.) I asked a couple self-professed Linux gurus, and one suggested lsof -p <pid>
, while the other suggested ls /proc/<pid>/fd
, but neither was positive about which more accurately reflects the actual count towards the max open files limit for a process.
So, which is it?
lsof -p <pid> | wc -l
Or
ls /proc/<pid>/fd | wc -l
Please elaborate on the difference. Thanks!