A problematic bug in simple-init can be resolved by eliminating one variable. Specifically, change:-
$wait=60*60*24;
while($active&& $running) {
(undef,$wait)=select(undef,undef,undef,$wait);
}
to:-
while($active&& $running) {
select(undef,undef,undef,60*60*24);
}
or suchlike. This change eliminates the case where the variable is zero and a busy wait on select() ensues.
Minor bugs remain. Regardless, simple-init is now suitable for deployment on systems which do not require suspend.
(Score: 2) by Knowledge Troll on Thursday August 18 2016, @04:48PM
Is this perl 5? Are you using select() as a higher resolution sleep than sleep()? Is this expected to be portable? If so I think you have a problem on your hands as select() does not always act well behaved.
Time::HiRes with the higher precision sleep is what I would do if this was perl 5 - as well as checking the time before and after calling what ever sleep() variant I used to make sure the correct amount of time has passed or return to sleeping if not.
This code looks optimistic and optimistic system code is dangerous.