When I use netstat, it shows the sockets my application is using. Great. However, randomly it starts showing them under a completely different program: sh. It started happening at least since I started stress testing it over 1000+ sockets (file descriptors). It could have been happening before that, I don't know I had other issues to work out. I'm using Asio.
Does anybody have the slightest idea what could be happening here?
The process id for sh seems to change too.. 5365/sh, 4192/sh, 1736/sh.
Then, out of the blue, it starts showing them back under my program name. It goes back and forth every 3-10 minutes. I feel this may also be causing a bug where all of my sockets suddenly go invalid.
What the heck? Any information greatly appreciated!
You do know that sh is bash/the shell? Not that that totally explains this, but it makes it somewhat less strange.
Ya I forgot to mention that's what I thought sh might be, and I am running it from a terminal (sh shows up in the system monitor - but I didn't think it's process id changed - so it must be using the terminal process id).
Originally Posted by MK27
So somehow my application is switching it's parenthood of the file descriptors to the shell I'm running the application under?
I wonder if this could be a socket.cancel() bug.. ran into it on Windows but Asio had a macro fix.
I'll keep tweaking and looking around.
May be your program from time to time use system() function ?
That's my guess as well. All open file descriptors get propagated to any child process. A call to system() would definitely show up as "sh" in the process list.
Originally Posted by Valery Reznic
A little too late but that was it guys. I didn't know that's how it worked, thanks. :)
I was opening netstat with popen() from within my application.
Is there any way to avoid that from happening? I'd like to get a count of how many real connections my application is using (monitor).
It might have been doing that because of canceling sockets, it appears unreliable in Asio - I'm not always getting my callbacks, which means the sockets don't always get closed. That might cause the sockets to appear under a different process. Might be something else. I'm gonna try a different solution - pass my callbacks to a deadline timer.