delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/08/30/05:16:53

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Subject: tcsetattr timeout problem ?
MIME-Version: 1.0
Date: Fri, 30 Aug 2002 11:17:27 +0200
Message-ID: <2DFB37B7D3EBFD4BB4FEDEC443C50B3302C827@mailserver>
X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0
X-MS-Has-Attach:
content-class: urn:content-classes:message
X-MS-TNEF-Correlator:
From: "Franck Leray" <franck DOT leray AT cheops DOT fr>
To: <cygwin AT cygwin DOT com>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id g7U9Grn30814

Hi all,

I've got a problem with reading a caracter with timeout.
Here is the source file:

The timeout don't seem to be activate.

Thanks.


#include <unistd.h>
#include <stdio.h>
#include <termios.h>
int main ()
{
   struct termios new_settings;
   struct termios stored_settings;
   int timeout=2;
   char c;

   tcgetattr (0, &stored_settings);
   new_settings = stored_settings;

   new_settings.c_lflag &= ~(ICANON | ECHO);
   
   new_settings.c_cc[VTIME] = timeout * 10; /* 2secs */
   new_settings.c_cc[VMIN]  = 0;
   tcsetattr (0, TCSANOW, &new_settings);

   do
     {
       printf("character:");
       fflush(stdout);
       c = getchar ();
       printf ("%d\t%c\n", c, c);
     }
   while (c != 'q');

   tcsetattr (0, TCSANOW, &stored_settings);
   return 0;
}

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019