Thank you for pointing out that flaw,
gam3 - I had figured the timestamp was more granular than that. I will try something like you have suggested instead.
However, I'm thinking of several other options:
- Not requiring a program to remove itself from the queue. This will force the other programs to check to see if the process is still running, yes, but a process could always die, so, IMHO, I think the check_queue would always have to have a kill 0.
- Having a program signal the next process to wake up by sending an alarm and then bumping the sleep length up to a larger number. The wasted time between one process execution and another is less important than the wasted CPU cycles from waking up and checking on processes.
Update: I just thought of this... what if instead of the single queue file, or creating a file named PID.lock and sorting by modification time, I were to use Time::HiRes' gettimeofday and name the file gettimeofday.PID.lock (with the values in there of course)
Then... sorting the files numerically, should work, no?
--------------
"But what of all those sweet words you spoke in private?"
"Oh that's just what we call pillow talk, baby, that's all."