home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!wupost!usc!news!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.lang.perl
- Subject: Re: $| for stdin?
- Keywords: stdin $| and life
- Message-ID: <1992Nov6.203330.22254@netlabs.com>
- Date: 6 Nov 92 20:33:30 GMT
- References: <1992Nov4.235759.14315@utagraph.uta.edu>
- Organization: NetLabs, Inc.
- Lines: 21
-
- In article <1992Nov4.235759.14315@utagraph.uta.edu> turbo@cse.uta.edu (Chris Turbeville) writes:
- : I am looking for some way of clearing standard in before every read.
- : You know the stdin counter-part of $|. I have a large program
- : responsable for helping non-unices do unix admin things safely but I
- : can't seem to keep it from getting a wrong char occasionally. If the
- : enter key is a little sticky then I get default responses when they may
- : have wanted to enter something just because their fingers are a little
- : heavy. Does anyone know of a way to flush stdin up to now (by now I
- : mean some point in the code) and then read something so these extra \n's
- : won't clutter up the place. I have tried seeks and all sorts of
- : trickery but to naught.
- : Thanks in advance
- : -Chris
-
- The solution space for this problem is system dependent. You'll likely
- need to play around with ioctl() or fcntl(). Essentially, you either
- need some kind of non-blocking read (see FIONBIO for ioctl() or FNDELAY
- for fcntl()) or some way of determining beforehand whether a read
- *would* block (and avoiding the read if so), such as FIONREAD for ioctl().
-
- Larry
-