Broken alarm(3)

Chuck Forsberg WA7KGX caf at omen.com
Sun Jun 12 21:12:04 UTC 2005


I don't know when, but the alarm system call no longer works
properly.  The following program works on Unix but not
Linux FC4t3 or FC3.  This is the mechanism rz/sz use for 
generating protocol timeouts.

#include <stdio.h>
#include <setjmp.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <termios.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include <setjmp.h>

jmp_buf timedout;		/* For the timeout interrupt on RX timeout */
void
alrm(c)
{
	longjmp(timedout, -1);
}
char linbuf[33];
main()
{
	int c;
	int n = 4;

	printf ("This program should time out every 4 seconds\n");
	for (;;) {
		printf("Calling read: alarm=%d \n ", n );
	if (setjmp(timedout)) {
			printf("Readline:TIMEOUT\n");
		continue;
	}
	signal(SIGALRM, alrm);
	alarm(n);
	errno = 0;
	c = read(0, linbuf, 22);
	alarm(0);
	printf("Read returned %d\n", n);
	}
}


-- 
Chuck Forsberg    caf at omen.com   www.omen.com   503-614-0430
Developer of Industrial ZMODEM(Tm) for Embedded Applications
  Omen Technology Inc      "The High Reliability Software"
10255 NW Old Cornelius Pass Portland OR 97231   FAX 629-0665




More information about the fedora-test-list mailing list