>>>>> "SS" == Sooraj S <soorajspadmanab...@gmail.com> writes:

  SS> Hi,
  SS> Could any one tell me what is wrong with my code? It does not time out
  SS> after 5 seconds which is what i need. It remains in the infinit loop.

  SS> while (1) { };

your bug is here. you never exit the loop.

  SS> eval
  SS> {
  SS>       alarm 5;  #timeout is 60
  SS> }

so this eval is never executed.

you need to but the alarm before the loop starts and wrap the loop in
the eval block. then the eval can trap the exit and you can timeout the
loop.

see the examples in perldoc perlipc for more on how to use alarm.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to