Broken alarm(3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx   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


[Index of Archives]     [Fedora Desktop]     [Fedora SELinux]     [Photo Sharing]     [Yosemite Forum]     [KDE Users]