Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jul 1997 23:37:20 -0700
From:      Josh MacDonald <jmacd@CS.Berkeley.EDU>
To:        Paul Traina <pst@shockwave.com>
Cc:        hackers@freebsd.org
Subject:   Re: how to tell if getchar() will block -- select doesn't cut it 
Message-ID:  <199707230637.XAA20188@paris.CS.Berkeley.EDU>
In-Reply-To: Your message of "Tue, 22 Jul 1997 23:17:39 PDT." <199707230617.XAA13468@precipice.shockwave.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
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
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707230637.XAA20188>