in reply to Do Perl Programs Timeout on Their Own

Do Perl programs automatically time out in a certain amount of time?
No.

But it may be stuck in a blocking I/O call, running an infinite loop, stopped after receiving SIGSTOP, or sleeping. Depending on your OS, you may (or may not) have tools available to see what a running program is doing.

  • Comment on Re: Do Perl Programs Timeout on Their Own

Replies are listed 'Best First'.
Re^2: Do Perl Programs Timeout on Their Own
by ahuang14 (Novice) on Jul 21, 2011 at 13:25 UTC
    There has been a new entry in the Snort file about every minute basically and maybe not so much over night when no one is at work, but definitely more often after it timed out at least until around 6 or 7. I didn't have a SIGSTOP and I dont know if it slept by itself. I actually do want it to run an infinite loop basically so that it will run as long as a new entry comes into the program. Maybe I should just try putting it all in an explicit infinite loop of like x=1 to see if that works.

      Difficult to guess without much code, but did you consider the case that your perl couldn't read anymore from the file and happily left the loop you have programmed? Perl jumps out the loop if the result is undef in your statement.

      This is possible in different cases. For example if Perl is much faster then 'Snort' and 'Snort' is blocking the file while writing. Or you log is somewhere rotated by a deamon on your system and the file doesn't exists anymore as happens on any Linux system?

      Catching errors and couple print statements to a small log file can give you a clue where and when your perl program quited.

      For such cases (waiting for another program to append a file) i think it is better to not let the file handle the whole time open. Open the file, read everything till the EOF, sleep and restart. Use a variable to keep the track of the position in the log, for example via a time stamp in the log. Seek to the last position and start from there.

      Regards

      Martell