Seriously Weird

This is a discussion on Seriously Weird within the Linux Programming forums, part of the Platform Specific Boards category; When I use netstat, it shows the sockets my application is using. Great. However, randomly it starts showing them under ...

  1. #1
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034

    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, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    You do know that sh is bash/the shell? Not that that totally explains this, but it makes it somewhat less strange.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    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, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    32
    May be your program from time to time use system() function ?

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    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.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    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, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed

Similar Threads

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

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