Re:A Unix Utility to Know About: lsof (2009)
by amelius on Friday August 26, 2016 @03:58AM
(#12364885)
What kernel functions does this command invoke to retrieve this information? How could I write my own version of lsof?
[ Parent
| on HN ]
Re:A Unix Utility to Know About: lsof (2009)
by b3h3moth on Friday August 26, 2016 @04:58AM
(#12365051)
The 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
Re:A Unix Utility to Know About: lsof (2009)
by spc476 on Friday August 26, 2016 @04:13AM
(#12364925)
On Linux, it probably uses files under /proc. For other systems, I don't know.
Re:A Unix Utility to Know About: lsof (2009)
by nailer on Friday August 26, 2016 @05:21AM
(#12365140)
strace it and see. As the other poster notes probably open() call to procfs or stat()
Re:A Unix Utility to Know About: lsof (2009)
by thesmallestcat on Friday August 26, 2016 @08:26AM
(#12365687)
If this sort of thing interests you, I cannot recommend https://www.nostarch.com/tlpi enough. The hardcover is worth every penny.