From owner-freebsd-hackers Tue Jul 22 23:37:23 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id XAA28193 for hackers-outgoing; Tue, 22 Jul 1997 23:37:23 -0700 (PDT) Received: from paris.CS.Berkeley.EDU (paris.CS.Berkeley.EDU [128.32.34.47]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id XAA28188 for ; Tue, 22 Jul 1997 23:37:19 -0700 (PDT) Received: from paris.CS.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by paris.CS.Berkeley.EDU (8.8.3/8.8.2) with ESMTP id XAA20188; Tue, 22 Jul 1997 23:37:25 -0700 (PDT) From: Josh MacDonald Message-Id: <199707230637.XAA20188@paris.CS.Berkeley.EDU> To: Paul Traina cc: hackers@freebsd.org Subject: Re: how to tell if getchar() will block -- select doesn't cut it In-reply-to: Your message of "Tue, 22 Jul 1997 23:17:39 PDT." <199707230617.XAA13468@precipice.shockwave.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20181.869639838.1@paris.CS.Berkeley.EDU> Date: Tue, 22 Jul 1997 23:37:20 -0700 Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk It's a bad idea to try and use the stdio library while trying to be select() aware in the first place. It's a bad practice to make non- blocking reads when you don't think anything is available because you'll end up spinning with no input available. Then your line editor chews CPU while idle. If I were you I would write the 30 or 40 lines of code that replace stdio's getchar with whatever you need for user input that is integrated with your select event loop. -josh > Yeah, I had thought of that, however, that means that the whole code-loop > is forced to become non-blocking aware. I use that technique in some > other places in related code. > > Thanks for the idea though, > > Paul >