4 ms·
What kernel functions does this command invoke to retrieve this information? How could I write my own version of lsof?
by amelius 10y ago
What kernel functions does this command invoke to retrieve this information? How could I write my own version of lsof?
- spc476 10y agoOn Linux, it probably uses files under /proc. For other systems, I don't know.
- b3h3moth 10y agoThe stat() family functions for sure, BSD Sockets, user account, covering everything from "process environement" to "filesystem" functions. "FAQ about lsof"[1] is very instructive. [1] ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
- nailer 10y agostrace it and see. As the other poster notes probably open() call to procfs or stat()
- thesmallestcat 10y agoIf this sort of thing interests you, I cannot recommend https://www.nostarch.com/tlpi https://www.nostarch.com/tlpi enough. The hardcover is worth every penny.