Menu

#21 read() hangs on Suse 8.1 with VMIN=0,VTIME=0

open
kernel (18)
5
2003-02-24
2003-02-24
No

in the following source code, the read() hangs forever
but only
on one system running Suse 8.1. Other systems with Suse 8.1
work. I cannot reproduce it on my own system
(former mandrake 8.0 with 2.4.20-abi).

I could deliver the linux-abi trace later, right now
the modem
of the problematic system does not answer. The trace
will show
that read() never returns.

(I need to generate SCO binaries because some libraries
are not
available for linux...)

Does anybody have an idea?

Btw I believe using fcntl(0,F_SETFL,O_NDELAY)
has the same problem, but I need to verify that when
the modem
answers again.

My program needs to check for kbd input without blocking.

Wolfgang

#include <termio.h>

int
main()
{
struct termio arg,oldarg;
char ch[2];
ioctl(0,TCGETA,&arg) ;
oldarg=arg;
arg.c_oflag = 0;
arg.c_lflag = 0;
arg.c_iflag &= ~INLCR & ~IGNCR & ~ICRNL & ~IUCLC ;
arg.c_cc[VQUIT] = 0377;
arg.c_cc[VMIN] = 0;
arg.c_cc[VTIME] = 0;
arg.c_cc[VINTR] = 0377;

ioctl(0,TCSETAW,&arg) ;
while (1) {
if (read(0,ch,1)) write(1,ch,1);
if (*ch=='x') break;
}
write(1,"\r\n",2);
ioctl(0,TCSETAW,&oldarg);
}

Discussion


Log in to post a comment.