serial port - ioctl's prevent subsequent reads

David Monniaux (David.Monniaux@ens.fr)
Thu, 18 Nov 1999 00:26:11 +0100 (MET)


Hi all,

using kernel 2.2.5 and glibc 2.1 (RedHat 6.0), I get the following weird
behaviour: the serial port being -crtscts and clocal, the following
program waits forever in tcdrain():

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>

main()
{
int fd, foo;
char totor[300];
fd=open("/dev/ttyS0", O_RDWR);
ioctl (fd, TIOCMSET, &foo);
write(fd, totor, 300);
fprintf(stderr, "maa\n");
tcdrain(fd);
fprintf(stderr, "moo\n");
}

It seems that the system does not transmit any data. However, removing the
ioctl line makes it run fine.

Why would i/o get blocked after such an ioctl?

[I'm becoming sick and tired of the serial driver second-guessing the
programmer. First, even when clocal is on, it resets the modem lines on
opening the device, which is plain stupid since clocal tells it to leave
these lines alone. Then it does weird things if I fiddle with them myself.
I add that code similar to the one above worked under 2.0 / libc 5.]

---
David Monniaux     Tel: +33 1 44 32 20 66    Fax: +33 1 44 32 20 80 
Laboratoire d'informatique de l'École Normale Supérieure,
45 rue d'Ulm - 75230 PARIS cedex 5 - FRANCE

- 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/