|more useful options|
blocking socket and alarmby InfiniteLoop (Hermit)
|on Sep 05, 2006 at 14:10 UTC||Need Help??|
InfiniteLoop has asked for the wisdom of the Perl Monks concerning the following question:
I have a script that opens a blocking socket to a messaging server, in a while(1) loop (it is a backgrounded processs). While the script is running, I want to interrupt the socket read process, say every 1 minute, and write a status message to, say, STDERR (basically I want to monitor the process). Here is how my code looks like this:
Although the alarm_signal is executed (not after 60 seconds), I get the:
Deep recursion on subroutine "Sys::AlarmCall::alarm_call" at ... error.
I feel Im not using the alarm properly here. How would you implement a way to interrupt a background process to print a debug message, periodically ?
I forgot to mention, this elaborate alarm call, is to monitor a messaging server. The socket read, is for the advisory message from the messaging server. Basically I wanted a "watch the watcher" kind of script, hence the interrupt to write a debug message.