proc_pidinfo(pid, PROC_PIDLISTFILEPORTS, 0, NULL, 0))
the retval of proc_pidinfo is always zero
how lsof works?
The issue here is that you’re asking for PROC_PIDLISTFILEPORTS
. That returns info about file ports, that is, Mach ports that wrap a file descriptor [1]. What you want is PROC_PIDLISTFDS
, which lists the file descriptors.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] File ports are one of those things that, IMO, should be API but aren’t )-: You can learn more about them in Darwin.