Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!ames!pasteur!ucbvax!tut.cis.ohio-state.edu!osu-cis!att!rutgers!orstcs!statware!scf From: scf@statware.UUCP (Steve Fullerton) Newsgroups: comp.sys.hp Subject: Re: buggy hp9000/800 3.01 code? Message-ID: <1901@statware.UUCP> Date: 3 Apr 89 16:29:31 GMT References: <659@kcdev.UUCP> <2980004@otter.hpl.hp.com> Reply-To: scf@statware.UUCP (Steve Fullerton) Organization: Statware, Corvallis, Oregon Lines: 42 In article <2980004@otter.hpl.hp.com> jp@otter.hpl.hp.com (Julian Perry) writes: >>The code we are using for raw input was extracted directly from Marc Roshkind's >>"Advanced UNIX Programming". Specifically, pages 88-89. He suggests >>termio.c_cc[VMIN] = 5 and termio.c_cc[VTIME] = 2. I wasn't sure whether >>or not the bug was related to VMIN and VTIME or else ICANON. I was >>finally able to get it to work by setting the VMIN value to 1 and the >>VTIME value to 0. > >The following code fragment is the correct way to set the terminal modes to >read one character at a time (blocking for each one): > > ioctl(0,TCGETA,&modes); /* Read the current settings */ > modes.c_lflag &= ~ICANON; /* Off with line mode */ > modes.c_cc[VMIN] = 1; /* Ask for 1 at a time */ > modes.c_cc[VTIME] = 0; /* Ignore the timer */ > ioctl(0,TCSETAW,&modes); /* Use the new settings */ This should probably read "correct for HP-UX 3.0". It doesn't explain why the code worked fine for HP-UX 2.0x, HP-UX 6.x (on the 300's) as well as on the Series 500's. The only thing that changed was the operating system revision from 2.0x to 3.0. The same code also works fine for every other non-BSD UNIX system I have tried which includes Pyramid, Sequent, AT&T 6386, Altos, Unisys 5000/7000, NCR Tower,..., the list is long. Furthermore, Rochkind's book "Advanced UNIX Programming" was supplied by HP with our manuals for our HP9000/825. To quote from the book, "The idea behind MIN and TIME is to allow a process to get characters as, or soon after, they are typed without losing the benefits of reading several characters with a single read system call." >I think that many implemetations of VMIN and VTIME are to ignore the timer >completely and effectively VMIN is always 1. HP-UX used to be like this >a long time ago. It's very MUX dependant. The idea of having VMIN and VTIME be MUX dependent is quite scary to me and would appear to make it non-SVID compliant. -- Steve Fullerton Statware, Inc. scf%statware.uucp@cs.orst.edu 260 SW Madison Ave, Suite 109 orstcs!statware!scf Corvallis, OR 97333 503/753-5382