We don't bite newbies here... much | |
PerlMonks |
Awake from sleep()by cmilfo (Hermit) |
on Nov 04, 2002 at 21:49 UTC ( [id://210307]=perlquestion: print w/replies, xml ) | Need Help?? |
cmilfo has asked for the wisdom of the Perl Monks concerning the following question:
Oh wisest Monks,
Is there a way to awake from the eternal sleep()? Two processes exist, a child doing the work and a parent checking that the other is still running. The parent ping()s the SOAP server the child is running, then sleep()s for N seconds. If the child dies just after the parent ping()s, then the process may be down for as much as N-1 seconds. The catch here is that the child is stopping on purpose, to replace a configuration file. This is an advantage, but I do not know exactly how to take advantage of it. Be it that the child stops itself, the parent can receive a signal from the child to stop what it's doing, sleep()ing. However, I've read over and over that one should limit what's done in a signal handler. So, the child signals the parent, then stops. The parent catchs the signal, and restarts the child. Before the parent can leave the signal handler, it will need to test the child (via SOAP) to ensure the child starts with the new configuration file, else replace the file and restart again.
1) Is this too much to do inside the singal handler? On a side note: Another solution is to shorten the sleep time of the parent. The problem here is that the parent process then has a larger system footprint (i.e. processor usage). Thank you once again, Casey
Back to
Seekers of Perl Wisdom
|
|