problems with read & alarm

Juantomas Garcia (juantomas@lared.es)
Sun, 06 Sep 1998 21:04:34 +0200


Hi,

In the last version of linux (2.0.32 and above) the behavior
of the read system call and the signals had change and I have
a lot of problems to manage it.

I have a lot of programs that works fine with code like this:

alarm(30);

ret = read (fd, &cc, 1);
alarm (0);

if (signalfired) {
then I handle it !!
}

working with old versions of the kernel and with many unixes
that work fine. I launched one alarm signal for 30 seconds. I have
code to handle the signal properly (I set a global flag if the signal
is fired).

if the read system call don't read any char from the serial port
the alarm is launched, I set my global flag and the read must be
return that a signal was launched.

That worked for a long time but now with new kernels the read
don't return when the signal alarm is fired. If you make a strace
a the program you "see" how the alarm signal is fired and how the
program stay in the system call read and never return.

I wonder if there is some special mode to set the file descriptor
in order to have the old style of read. I want to have blocking read
system calls and have signal way to wake up it if something wrong
is happening in the serial protocol.

I'm very concerned with that cose the unique OS that "fail" is the
last versions of Linux and the rest of unixes (even old ones) work
very fine ....

Thanks in advance
Juantomas Garcia

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/faq.html