Can I get the information stored in /proc
via system calls instead of processing text from files?
I am trying to list inotify watches which are preventing the unmount of a filesystem.
Ive written part of a shell script, but it's already too slow. I'm thinking of rewriting in Perl.
Is there a way to get the /proc
information from system calls for a further speed up?
No, there is no other interface to
/proc
nodes besides theopen()
andread()
system calls.Keep in mind that nodes under
/proc
aren't real files. Reads from them will return as quickly as the content can be generated by the kernel -- an alternate interface wouldn't be any faster.That all being said, reimplementing your shell script in any programming language that can read files directly (like Perl) will already speed it up dramatically. In a shell script, you're launching a new process, or possibly even multiple processes, every time you call
ls
orgrep
. Launching processes is relatively slow -- getting away from that will probably solve your speed problems.