From owner-freebsd-hackers Sun May 30 23:44:21 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from alpo.whistle.com (alpo.whistle.com [207.76.204.38]) by hub.freebsd.org (Postfix) with ESMTP id C484F14BF3 for ; Sun, 30 May 1999 23:44:19 -0700 (PDT) (envelope-from julian@whistle.com) Received: from current1.whistle.com (current1.whistle.com [207.76.205.22]) by alpo.whistle.com (8.9.1a/8.9.1) with SMTP id XAA49465 for ; Sun, 30 May 1999 23:44:18 -0700 (PDT) Date: Sun, 30 May 1999 23:44:16 -0700 (PDT) From: Julian Elischer To: hackers@freebsd.org Subject: sio driver and select puzzle. Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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