This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Problem with alarm() not functioning twice in one program.
- From: "Max Bowsher" <maxb at ukf dot net>
- To: <cygwin at cygwin dot com>
- Date: Tue, 8 Feb 2005 20:29:33 -0000
- Subject: Problem with alarm() not functioning twice in one program.
The following program produces the output:
Begin
Done
Begin
...and then hangs.
Can anyone help me understand why?
Thankyou,
Max.
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <unistd.h>
jmp_buf timer;
void alarm_handler(int dummy)
{
longjmp(timer, 1);
}
void speedtest(void)
{
fprintf(stderr, "Begin\n");
signal(SIGALRM, alarm_handler);
if (setjmp(timer) == 0) {
alarm(1);
while(1) {};
}
signal(SIGALRM, SIG_DFL);
fprintf(stderr, "Done\n");
return;
}
int main(int argc, char* argv[])
{
speedtest();
speedtest();
return 0;
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/