Date: Sun, 30 May 1999 23:44:16 -0700 (PDT) From: Julian Elischer <julian@whistle.com> To: hackers@freebsd.org Subject: sio driver and select puzzle. Message-ID: <Pine.BSF.3.95.990530233715.10396B-100000@current1.whistle.com>
next in thread | raw e-mail | index | archive | help
The following code is SUPPOSED to return to me when a
character is available for reading..
but it doesn't.
any one care to point out the obvious bug?
main()
{
int filedes;
struct termios newterm;
struct termios oldterm;
int child;
int retval;
struct perchild *cp;
int sel_nfds;
filedes = open("/dev/cuaa1", O_RDWR, 0);
if (filedes == -1)
err(1,"cant open cuaa1");
retval = tcgetattr(filedes, &oldterm);
if ( retval == -1)
err(1, " can't get termios");
newterm = oldterm;
newterm.c_cflag = CLOCAL | CREAD | CS8;
newterm.c_oflag = OPOST | ONLCR;
newterm.c_iflag = 0;
newterm.c_lflag = 0;
newterm.c_ispeed = B57600;
newterm.c_ospeed = B57600;
newterm.c_cc[VMIN] = 1;
newterm.c_cc[VTIME] = 0;
retval = tcsetattr(filedes, TCSAFLUSH, &newterm);
if ( retval == -1)
err(1, " can't set termios");
/*
* get role
*/
for(;;) {
sprintf(linebuf2, "%20s\n","1= test, 2=target");
write(filedes, linebuf2, strlen(linebuf2));
sprintf(linebuf2, "%20s\n","9= quit and reboot");
write(filedes, linebuf2, strlen(linebuf2));
sel_nfds = 0;
FD_ZERO(&read_set);
FD_SET( filedes, &read_set);
if (filedes > sel_nfds)
sel_nfds = filedes;
printf("select called %d\n",sel_nfds);
sel_nfds = select(sel_nfds, &read_set, NULL, NULL, NULL);
printf("select returned %d\n",sel_nfds);
[...]
the program gets to "select called %d"
but when I send a character down the line
it doesn't return from the select.
this is in 3.1 (approximatly)
If I comment out the select, the read that follows it (not shown) does get
the character.
julian
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.990530233715.10396B-100000>
