[Nottingham] Unix process open sockets

Roger Light roger at atchoo.org
Thu Jan 3 11:48:22 GMT 2008


Hi Phil,

>    Is there a way using perl that, given a process Id ($pid) I can
>    retrieve/display all the
>    associated sockets (unix/internet) of the corresponding unix process ?

The answer has to be "yes", but I'm not sure how to do it natively. I
suspect you might have to resort to looking in /proc/$pid but I don't
know what for... :)

Both netstat (with "netstat -ap") and lsof can retrieve this
information, so you could always either look at how they do it or parse
their output.

Good luck!

Cheers,

Roger



More information about the Nottingham mailing list