Read "/proc" to know if a process has opened a port
35
votes
6
answers
52479
views
I need to know if a process with a given PID has opened a port without using external commands.
I must then use the
/proc
filesystem. I can read the /proc/$PID/net/tcp
file for example and get information about TCP ports opened by the process. However, on a multithreaded process, the /proc/$PID/task/$TID
directory will also contains a net/tcp
file. My question is :
do I need to go over all the threads net/tcp
files, or will the port opened by threads be written into the process net/tcp
file.
Asked by rmonjo
(453 rep)
Aug 29, 2015, 01:11 PM
Last activity: May 5, 2025, 04:35 PM
Last activity: May 5, 2025, 04:35 PM