Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!rochester!rutgers!husc6!sri-unix!ctnews!pyramid!prls!philabs!micomvax!musocs!mcgill-vision!mouse
From: mouse@mcgill-vision.UUCP (der Mouse)
Newsgroups: comp.lang.c,comp.unix.questions
Subject: Re: Keyboard Input (Revised Question) ...
Message-ID: <847@mcgill-vision.UUCP>
Date: Thu, 23-Jul-87 21:09:56 EDT
Article-I.D.: mcgill-v.847
Posted: Thu Jul 23 21:09:56 1987
Date-Received: Wed, 29-Jul-87 06:11:38 EDT
References: <1043@bucsb.bu.edu.UUCP> <805@nu3b2.UUCP>
Organization: McGill University, Montreal
Lines: 36
Keywords: Keyboard
Xref: mnetor comp.lang.c:3332 comp.unix.questions:3379

In article <805@nu3b2.UUCP>, rwhite@nu3b2.UUCP (Robert C. White Jr.) writes:
> In article <1043@bucsb.bu.edu.UUCP>, eap@bucsb.bu.edu.UUCP (Eric Pearce) writes:
>> I used to be able to do this [check for keyboard input without
>> waiting] easily on my Apple ][.
>> Is there a way to do this in C?

This is a system-dependent area; presumably you are talking about C
under UNIX.  C per se does not address this sort of question - all
operating system interface issues are handled through library routines.

Unfortunately, there is enough variation across different versions of
UNIX to make it impossible to give a blanket answer.

> [U]se the function ioctl to set O_NDELAY on standard input,

Please specify what flavor of UNIX!  Under 4.3 BSD, for example,
O_NDELAY is a flag to open(), not something one uses with ioctl() (the
ioctl() is called FIONBIO, also usable with fcntl()).

> [if no input and not EOF], read will return -1 and errno will be set
> to EAGAIN.

Another difference.  Under 4.3, errno is set to EWOULDBLOCK.  Please
qualify such statements with what flavor of operating system your
question or answer is for!  (Yes rwhite, I know you said "on our
system", but that doesn't help eap decide whether it applies to his
system.)

So, to sum up: it depends on your system.  Under most (all?) current
variants of UNIX, it is possible, but the details of how depend on the
particular system.  (I can provide detail for 4.3BSD UNIX, and general
ideas for 4.2BSD, but please send mail rather than cluttering the net!)

					der Mouse

				(mouse@mcgill-vision.uucp)