It looks like your hibernation code is interrupted by some code that sets the alarm. This is by design, so you see the expected behavior. In other words, the alarm * should always interrupt the sleep call.
If you are looking for a clean perl sleep path without interrupting an alarm, you can do this by installing your own alarm handler. Thus, when your code receives an alarm, it does not interrupt your processing.
However, it is important to beware that this delays any alarm set by another code. Another code will receive an alert late; after code completion. This means that if you want to play well with others, you are better off using one of the other solutions.
Here is an example:
#!/usr/bin/perl use POSIX; use strict; use warnings;
The documentation referenced by the prompts but does not describe another symptom. The main thing that you need to worry about when a dream is realized using an alarm is alarm reset when someone causes a dream.
* Apparently, there are several versions of perl (for example: old Win32) where the alarm does not interrupt sleep.
source share