From owner-freebsd-hackers Wed Jul 10 21:10:53 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6784A37B400 for ; Wed, 10 Jul 2002 21:10:48 -0700 (PDT) Received: from mail.tinkerbox.org (adsl-64-168-139-138.dsl.snfc21.pacbell.net [64.168.139.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id D1D9D43E52 for ; Wed, 10 Jul 2002 21:10:47 -0700 (PDT) (envelope-from bruno@tinkerbox.org) Received: from duron.bschwand.net (duron.bschwand.net [192.168.137.4]) by mail.tinkerbox.org (Postfix) with ESMTP id C2B9519B5 for ; Wed, 10 Jul 2002 21:13:18 -0700 (PDT) Date: Wed, 10 Jul 2002 21:13:18 -0700 (PDT) From: bruno schwander X-Sender: bruno@duron.bschwand.net To: hackers@freebsd.org Subject: termios guru ? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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