in reply to Re: New Child to Wait for First Child to Die
in thread New Child to Wait for First Child to Die

Good point! Only so that I can have
$SIG{"ALRM"} = sub { print "TIME_OUT! at $timeout\n"; exit; }; alarm ($timeout);
timeout the (child) process if the connection hangs. I don't really want to fork at all but I need a way of terminating the port check after a number of seconds and to jump to the next port. I tried something like
$SIG{"ALRM"} = sub { next; }; alarm($timeout);
But the SIG does not "happen" inside the loop so the  next fails. timeout the (child) proccess if the connection hangs. I don't realy want to fork at all but I need a way of terminating the port check after a number of secconds and to jump to the next port. I tried something like
$SIG{"ALRM"} = sub { next; }; alarm($timeout);
But the SIG does not "happen" inside the loop so the  nect fails.

Replies are listed 'Best First'.
Re: Re: Re: New Child to Wait for First Child to Die
by nothingmuch (Priest) on Apr 24, 2003 at 11:07 UTC
    Peek inside Net::Ping's source code, and see how tcp pings are implemented. That's the idiom for tcp timeouts, and is an elegant way of doing them safely.

    -nuffin
    zz zZ Z Z #!perl