popen takes too long?

This is a discussion on popen takes too long? within the C Programming forums, part of the General Programming Boards category; I'm writing a program to check whether servers are still alive. So I'm executing the ping command with popen, to ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    8

    popen takes too long?

    I'm writing a program to check whether servers are still alive. So I'm executing the ping command with popen, to make sure my program isn't blocked during the ping and I can execute a lot of pings in parallel. The problem however is that sometimes the popen command is blocked for a while and it takes seconds before it is executed.

    Here's the popen part of my program:

    Code:
    strcpy(command,"ping -c 1 -w 1 ");
    strcat(command,IpAddress);
    M_fp = popen(command,"r");
    I think it has something to do with a maximum open child processes or so, because this happens only when there are a lot of pings going on. Anybody an idea why this takes sometimes so long?

    Is there a function to retrieve the number of open child processes?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    > to make sure my program isn't blocked during the ping and I can execute a lot of pings in parallel.
    So you've just managed to DoS yourself, what do you want from us?

    Maybe find another way to solve your problem?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    8
    I'm doing something like 20 pings each second, so it's not that my server can't handle that.

    I would just like to know what the reason can be that sometimes popen takes a few seconds to execute.

    And I'd like to know how I can retrieve the number of open child processes

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. long int type
    By sarahr202 in forum C++ Programming
    Replies: 4
    Last Post: 05-20-2009, 12:55 PM
  2. How do i un-SHA1 hash something..
    By willc0de4food in forum C Programming
    Replies: 4
    Last Post: 09-14-2005, 05:59 AM
  3. Sorting Algorithms with Time
    By silicon in forum C++ Programming
    Replies: 3
    Last Post: 05-03-2005, 11:27 AM
  4. WSAAsyncGetHostByName takes quite long to return even on LAN
    By hanhao in forum Networking/Device Communication
    Replies: 2
    Last Post: 04-08-2004, 05:08 AM
  5. Replies: 3
    Last Post: 03-21-2004, 05:02 PM

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