Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!seismo!munnari!moncskermit!yarra!richb From: richb@yarra.OZ (Rich Burridge) Newsgroups: net.unix-wizards Subject: Problem with pseudo ttys on Sun. Message-ID: <3@yarra.OZ> Date: Sat, 5-Jul-86 20:34:10 EDT Article-I.D.: yarra.3 Posted: Sat Jul 5 20:34:10 1986 Date-Received: Mon, 7-Jul-86 00:49:12 EDT Organization: Sun Computer Australia (Melbourne) Lines: 67 Keywords: SUN ttyq0-ttyq6. Help is desperately needed with the following "problem". I am running Sun 3.0 (Generic) on a Sun 3/50 with an 112 Meg shoebox. I am trying to use the pseudo ttys ttyq0-ttyq6 to transfer data from other programs into my program. Inside my program I open say, ptyq5 (the MASTER pty) with: int fpty ; if (fpty = open("/dev/ptyq5",2)) < 0) { fprintf(stderr,"can't open pseudo\n") ; exit(1) ; } I then set it into RAW mode with: struct sgttyb pty ; gtty(fpty,&pty) ; pty.sg_flags |= RAW ; stty(fpty,&pty) ; Now to test if there is any thing to read on that pty, I use the select call. int readmask,nfds ; static struct timeval timeout = { 0,0 } ; readmask = 1 << fpty ; nfds = select(32,&readmask,(int *)0,(int *)0,&timeout) ; Say I used 'cat' to redirect a small file to /dev/ttyq5, as this was happening nfds returned a 1 to indicate that there was a file descriptor with outstanding data to be read, and the readmask had the appropriate bit set. So, I read the data from the pseudo tty with: #define MAXDATA 32 char buffer[MAXDATA] ; int nread ; if (nfds ==1) nread = read(fpty,buffer,MAXDATA) ; nread normally contains the number of bytes read (which will be MAXDATA, up until the "last" time which will return a smaller value; the remainder left to read). Now what I would expect is that when I come to do the select call again, it should return 0 and the readmask should also be zero. But no, it tells me that there is data to be read, and when I use the read call as above, it returns -1 in nread with errno set to 5 (EIO I/O error). Where am I going wrong? Please answer by mail, as I'm about a week behind reading the net. Thanks in advance. Rich Burridge ISD: +61 3 267-6222 Sun Australia STD: (03) 267-6222 14 Queens Rd, ARPA: richb%yarra.oz@seismo.arpa Melbourne, VIC 3004. UUCP: seismo!munnari!yarra.oz!richb AUSTRALIA. ACS: richb@yarra.oz D