PDA

View Full Version : A Perl question



epoch1970
2012-09-18, 13:00
I want to write a daemon that launches long-lived processes (it's a backup robot.)
I can't have the daemon stand there waiting on the children, backgrounding the system processes is necessary.
The background processes have an unfortunate tendency to lock-up. So the daemon needs to be able to check on progress, kill hung tasks and hopefully rollback…

I started using non-blocking fork/exec and reaping zombies with SIG CHILD. I don't seem to be able to add SIG ALRM to the mix (I tried w/ alarm and ualarm), because some of my code currently uses sleep().

Since I might like a good sleep from time to time, I started looking at Proc::Background and it seems to offer a solution. Cleaner than a fork/exec sub, easy to get status from the objects so I could poll them instead of using alarms. (Performance is not an issue, reliability is.)

So this is my question: what would you use to perform something similar to fork/exec, with timeout/kill handling ?
(The final code will run in a Net:: Daemon loop, FWIW)

Thanks for any hint!

pallfreeman
2012-09-18, 15:31
Do the alarm handling in the child processes; wrapper probably simplest way?

epoch1970
2012-09-18, 15:46
Do the alarm handling in the child processes; wrapper probably simplest way?

Ah yes. I was focused on the parent code, but of course I can make the spawned children
process smarter.
Now I have a solution, no matter what.
Thanks!