2002-05-01 00:29:11

by David Dyck

[permalink] [raw]
Subject: changes between 2.2.20 and 2.4.x 'broke' select() from detecting input characters in my serial /dev/ttyS0 program


I have a program that opened "/dev/ttyS0" twice,
once as O_RDONLY, and once as O_WRONLY
(I know now that I could have opened only one channel O_RDWR)

The program used tcsetattr( ,TCSANOW, ) to modify
c_iflag, c_oflag, and c_cflag for both channels.
first for the O_RDONLY channel, and then for the O_WRONLY.

Later the program used select() on the O_RDONLY channel to
detect characters, and read() to extract them from the driver.
This used to work in 2.2.x, (2.2.20) but select() now reports no characters
available on 2.4.x (today it is 2.4.19-pre7-ac3).

If I change the order of the tcsetattr() to modify the O_RDONLY
after the O_WRONLY channel, then it works on both 2.2.x and 2.4.x.
I have a workaround (by changing the order), but this order
dependency is not documented and I wonder if it is some new
feature, or a bug.
(I think it is a bug)

I have a 158 line program that I use to demonstrate the
bug that I could email if requested.

I am wondering what changed between 2.2.x and 2.4.x that
could have caused this change in behaviour.

It turns out also that the O_WRONLY channel had CREAD turned off,
which I would expect was appropriate for an output channel, and
in 2.2 kernels, it didn't affect the O_RDONLY channel. If I enable
the CREAD bit in termios c_cflag register for the O_WRONLY channel also
then the select on the O_RDONLY channel reports characters available.

I suspect that there is a different level of information sharing
between the 2 channels that are open, but which is the correct behaviour,
and why?

David

I've addressed this email to those that have modified
the code since 2.2.20, maybe these symtoms will ring a bell.
Perhaps the change that causes this is outside of serial.c.