Timing: fix set_alarm(0) on Unix/POSIX
The POSIX/Unix implementation of set_alarm did not set the
alarmed flag when called with 0, which was inconsistent
with what the documentation implied and with the Windows behavior.
diff --git a/library/timing.c b/library/timing.c
index 50410df..6e7f93f 100644
--- a/library/timing.c
+++ b/library/timing.c
@@ -318,6 +318,12 @@
alarmed = 0;
signal( SIGALRM, sighandler );
alarm( seconds );
+ if( seconds == 0 )
+ {
+ /* alarm(0) cancelled any previous pending alarm, but the
+ handler won't fire, so raise the flag straight away. */
+ alarmed = 1;
+ }
}
void m_sleep( int milliseconds )