dalance / bsd-kvm

1 stars 0 forks source link

Can `libkvm` be used to gather open sockets info? #3

Open GyulyVGC opened 4 months ago

GyulyVGC commented 4 months ago

Disclaimer: this is more a discussion than an issue, but this repo doesn't have the Discussion section.


First of all thank you for this handy library! I'm trying to interact with the BSD kernel and I was having lots of headaches until I found your crate. Thanks to bsd-kvm I've managed to retrieve the name and PID of all active processes.

Now, since I'm trying to implement a sort of cross-platform Rust-based netstat, I'd like to know whether the information exposed by this library is sufficient to get a list of the open sockets for each process. Any suggestion will be warmly appreciated.


_I'm asking here since the official documentation seems to not be enough exhaustive. For example, this documents the kvm_getprocs function, but it doesn't even specify the role of the arg parameter._

dalance commented 4 months ago

I found the usage of kvm_getprocs through code reading of ps in FreeBSD. So I think the code of netstat may be helpful.

https://github.com/freebsd/freebsd-src/tree/main/usr.bin/netstat