delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2002/08/30/10:55:47

Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT cygwin DOT com>
List-Help: <mailto:cygwin-developers-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT cygwin DOT com
Delivered-To: mailing list cygwin-developers AT cygwin DOT com
Date: Fri, 30 Aug 2002 10:55:41 -0400
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin-developers AT cygwin DOT com
Subject: [franck DOT leray AT cheops DOT fr: tcsetattr timeout problem ?]
Message-ID: <20020830145541.GB1402@redhat.com>
Mail-Followup-To: cygwin-developers AT cygwin DOT com
Mime-Version: 1.0
User-Agent: Mutt/1.3.23.1i

So, did you put someone up to this, Egor?  :-)

cgf

----- Forwarded message from Franck Leray <franck DOT leray AT cheops DOT fr> -----

From: "Franck Leray" <franck DOT leray AT cheops DOT fr>
To: <cygwin AT cygwin DOT com>
Subject: tcsetattr timeout problem ?
Date: Fri, 30 Aug 2002 11:17:27 +0200
Mail-Followup-To: cygwin AT cygwin DOT com

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;
}

----- End forwarded message -----

- Raw text -


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