C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-10-2009, 07:24 AM   #1
Dae
Deprecated
 
Dae's Avatar
 
Join Date: Oct 2004
Location: Canada
Posts: 944
Seriously Weird

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!
__________________
Warning: Have doubt in anything I post.

GCC 4.5.0 (lambda branch), Boost 1.40.0, Code::Blocks 8.02, Ubuntu 9.04 010001000110000101100101
Dae is offline   Reply With Quote
Old 09-10-2009, 07:25 AM   #2
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,944
You do know that sh is bash/the shell? Not that that totally explains this, but it makes it somewhat less strange.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Old 09-10-2009, 07:50 AM   #3
Dae
Deprecated
 
Dae's Avatar
 
Join Date: Oct 2004
Location: Canada
Posts: 944
Quote:
Originally Posted by MK27 View Post
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).

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.
__________________
Warning: Have doubt in anything I post.

GCC 4.5.0 (lambda branch), Boost 1.40.0, Code::Blocks 8.02, Ubuntu 9.04 010001000110000101100101
Dae is offline   Reply With Quote
Old 09-10-2009, 10:42 PM   #4
Registered User
 
Join Date: Oct 2007
Posts: 22
May be your program from time to time use system() function ?
Valery Reznic is offline   Reply With Quote
Old 09-11-2009, 12:52 AM   #5
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,381
Quote:
Originally Posted by Valery Reznic View Post
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.
__________________
"Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot
brewbuck is offline   Reply With Quote
Old 09-11-2009, 02:40 AM   #6
Dae
Deprecated
 
Dae's Avatar
 
Join Date: Oct 2004
Location: Canada
Posts: 944
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.
__________________
Warning: Have doubt in anything I post.

GCC 4.5.0 (lambda branch), Boost 1.40.0, Code::Blocks 8.02, Ubuntu 9.04 010001000110000101100101
Dae is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
weird things with my linked list of queue -EquinoX- C Programming 3 11-22-2008 11:23 PM
weird kiz C Programming 8 09-24-2007 01:16 AM
Weird Characters With GetDlgItemText execute Windows Programming 4 05-04-2006 04:53 PM
weird error gandalf_bar Linux Programming 2 07-17-2005 07:32 AM
Getting weird characters in Strings steve8820 C Programming 3 09-18-2001 02:49 AM


All times are GMT -6. The time now is 04:33 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22