This was my answer to your request for an algorithm that
could recursively call itself. Say $oldalarm is 3 and
$givetime is 20. Even though cheatmail may have 20 seconds
to complete its task, you know that somewhere higher in the
callstack, you have another watchdog (which I refer to as
a 'parent') that is expecting to be done one way or another
in 3 seconds. Using this algorithm, you know that whichever
watchdog is expecting to be done in 3 seconds will be the
one to receive the alarm signal.