problem with alarm()

Rob Janssen reading Linux mailinglist (linux@pe1chl.ampr.org)
Fri, 28 Jul 1995 15:00:54 +0200 (MET DST)


It looks like there is a problem with alarm() in at least 1.3.11.
The following program:

#include <stdio.h>

main ()

{
alarm(20);
getchar();
printf("%d\n",20-alarm(0));
return 0;
}

Always prints 0, unless the alarm timer is allowed to completely run out.
It should print the number of seconds until RETURN is hit, because the
alarm(0) should return the number of seconds left from the previous
alarm clock.

This works fine in earlier versions, at least in the 1.2 series. It
causes my ZyXEL program to fail, because it thinks a 0-second message
is being recorded.
(I am running 1.2.10 myself and got this report from users of my program.
a quick test on 1.3.11 shows it is indeed the case)

I don't see an obvious reason in sys_alarm itself, so it probably is
a result of the scheduler changes...

Rob

-- 
+------------------------------------+--------------------------------------+
| Rob Janssen         rob@knoware.nl | AMPRnet:   rob@pe1chl.ampr.org       |
| e-mail: pe1chl@wab-tis.rabobank.nl | AX.25 BBS: PE1CHL@PI8WNO.#UTR.NLD.EU |
+------------------------------------+--------------------------------------+