linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Progga <abulfazl@juniv.edu>
To: linux-c-programming@vger.kernel.org
Subject: Re: getch()
Date: Fri, 8 Nov 2002 15:04:01 +0600	[thread overview]
Message-ID: <200211081504.01461.abulfazl@juniv.edu> (raw)
In-Reply-To: <20021107200436.C1136@neutrino.particles.org>


> 	tcgetattr(STDIN_FILENO, &attrib);
> 	attrib.c_lflag &= ~(ICANON|ECHO); /* disables canonical mode, echo */
> 	attrib.c_cc[VMIN] = 0;            /* non-blocking input */
> 	attrib.c_cc[VTIME] = 0;
> 	tcsetattr(STDIN_FILENO, TCSAFLUSH, &attrib);

 Thanks all for the super suggestions. I only had to change one line for 
getting what I need :

 > 	attrib.c_cc[VMIN] = 0;            /* non-blocking input */
to
 	attrib.c_cc[VMIN] = 1;            /* blocking input */

 If input is taken in non-blocking mode then something like:

  while( read( STDIN_FILENO, &ch, 1 ) != 1 ) ;

  needs to be used. It's also OK. But to use getchar()/cin, using blocking 
mode appeared the most suitable. So I did the change. The chance to control 
the echo and nonecho mode is another beauty. I needed the nonecho and it was 
already in the code. Thanks again from me and my friend Mahbub.

 Khoda Hafez 
 Progga


  parent reply	other threads:[~2002-11-08  9:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200211071046.24987.abulfazl@juniv.edu>
2002-11-07 15:35 ` getch() Progga
2002-11-07 18:04   ` getch() Elias Athanasopoulos
2002-11-07 17:19     ` getch() Glynn Clements
2002-11-07 20:58       ` getch() Elias Athanasopoulos
2002-11-08  9:04     ` Progga [this message]
2002-11-08 17:51       ` getch() Glynn Clements
2002-12-05 12:17       ` defining a #define Christopher Quinn
2002-12-05 13:22         ` Miguel Griffa
2002-12-05 13:36           ` Christopher Quinn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200211081504.01461.abulfazl@juniv.edu \
    --to=abulfazl@juniv.edu \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).