Results 1 to 2 of 2
While running some live tests last week I saw an odd situation where netstat appeared to be displaying the wrong PID and process name for TCP connections. I'm trying to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-10-2010 #1
- Join Date
- Dec 2009
netstat displaying wrong process name/id?
We have a main program which establishes a number of connections, including connecting to a JMS server and listening/accepting a TCP connection. The main program also creates a child process which it uses to communicate with another server. On at least three occasions we saw a situation we saw netstat reporting all the expected TCP connections (correct ip/port for both source and destination), however the child process, instead of the main, was listed for the PID. The main process was still running but netstat no longer reported any TCP connections established by the main program. The main program continued to function correctly, the JMS communication continued to work and we believe the other TCP connection was functioning correctly despite the program supposedly not having any TCP connections.
I'm wondering if this could simply be a bug and/or obscure functionality of netstat that I don't understand which would cause netstat to report the child process as 'owning' the parents TCP connections. I don't know how this would happen or why the parent would continue functioning despite the problem otherwise.
- 02-28-2010 #2
- Join Date
- Jan 2005
- Saint Paul, MN
In UNIX (and also Linux) when the "fork" function is called to create a new process, the child process has all the file descriptors that the parent had. The code in the child should close all file descriptors that it is not going to be using (i.e. should close all opened file descriptors unless the child is to use them).