cmilfo has asked for the wisdom of the Perl Monks concerning the following question:
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?
2) If 1) is 'yes', is there a way to leave the signal handler, break from the sleep(), and then attempt to restart the child, test, etc?
3) Is there a better way than a signal to telling the sleep()ing parent that the child is stopping?
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Awake from sleep()
by Zaxo (Archbishop) on Nov 04, 2002 at 22:41 UTC | |
by cmilfo (Hermit) on Nov 04, 2002 at 22:49 UTC | |
by agentv (Friar) on Nov 04, 2002 at 23:25 UTC | |
by cmilfo (Hermit) on Nov 05, 2002 at 05:47 UTC | |
Re: Awake from sleep()
by John M. Dlugosz (Monsignor) on Nov 04, 2002 at 22:32 UTC | |
by cmilfo (Hermit) on Nov 04, 2002 at 22:57 UTC | |
by John M. Dlugosz (Monsignor) on Nov 04, 2002 at 23:00 UTC | |
Re: Awake from sleep()
by BrowserUk (Patriarch) on Nov 04, 2002 at 23:51 UTC |