in reply to Monitor Perl script within the same script?

I think you can use the alarm-function. (perldoc -f alarm)
  • Comment on Re: Monitor Perl script within the same script?

Replies are listed 'Best First'.
Re^2: Monitor Perl script within the same script?
by perlMunger (Novice) on Dec 15, 2004 at 16:04 UTC
    Animator, thanks for the help. After reading the docs (perldoc -f alarm), I still can't seem to figure out who to use it within a sub/function. Should I fork a process from the sub to monitor the parent? If so, do you have any suggestions that might help me with my quest. TIA! perlMunger
      It's been quite some time since I've written anything dealing with alarm but something like this may do what you need

      $SIG{ALRM} = sub { #cleanup lockfile #cleanup anything else exit; } alarm(1200); # do stuff # If you have system calls here (i.e. sysread) you # may need to do some wrapping with eval etc. (as per # the alarm perldoc alarm(0);
      This is untested. I think the approach will work, but as always, you mileage may vary. Update: time is in seconds not minutes.