This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[franck.leray@cheops.fr: tcsetattr timeout problem ?]


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

cgf

----- Forwarded message from Franck Leray <franck.leray@cheops.fr> -----

From: "Franck Leray" <franck.leray@cheops.fr>
To: <cygwin@cygwin.com>
Subject: tcsetattr timeout problem ?
Date: Fri, 30 Aug 2002 11:17:27 +0200
Mail-Followup-To: cygwin@cygwin.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 -----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]