Date: Wed, 10 Jul 2002 21:13:18 -0700 (PDT) From: bruno schwander <bruno@tinkerbox.org> To: hackers@freebsd.org Subject: termios guru ? Message-ID: <Pine.BSF.4.21.0207102056320.287-100000@duron.bschwand.net>
next in thread | raw e-mail | index | archive | help
I making a port (not much really) of Irit (http://www.cs.technion.ac.il/~irit/) a modelling environment. I am having some problems with terminal handling, so all termios guru out there, please help ! :-) At stratup, irit does the following Termio.c_cc[VEOF] = 0; /* MIN = 0, no minimal length to wait for. */ Termio.c_cc[VEOL] = 1; /* TIME - 1 tenth of a second as time o which seems wrong, I think it should be Termio.c_cc[VMIN] = 0; /* MIN = 0, no minimal length to wait for. */ Termio.c_cc[VTIME] = 1; /* TIME - 1 tenth of a second as time o then later: Termio.c_lflag &= ~ICANON; basically, irit wants to manage line editing itself, to manage the irit command prompt. There is some code doing the ^A, ^H, etc handling and line printing, and reading periodically stdin. What I see happening, is that usually at the very beginning, input seems locked. Running in the debugger, I see that characters are fgetc'ed periodically, but fgetc always returns -1 even when there should be characters available. I then tried using fcntl(0, F_SETFL, O_NONBLOCK) instead of the above 2 lines. which I thought would do the right thing, ie: non blocking IO, but anything available from stdin is buffered and provided on the next read. This works, however I am seeing something strange on stdout now: when outputting lots of lines, outputs stalls after a few dozen lines. Adding a usleep between each fwrite() solves the problem but slows it all down... (and is inherently wrong) What is going on here ? I do not understand very well all the terminal/IO discipline here. I agree that this is all bad design, and should probably multithread or use select() but I am not Irit's author... bruno 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.4.21.0207102056320.287-100000>