www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/07/13/22:19:28

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 56E2JRtX3985051
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 56E2JRtX3985051
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=bsPXMb1w
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B71B3858C66
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1752459565;
bh=m7rKo41TN9xmgjeTM4GQm86CaJ5BcaqtTEyqR9oYFVE=;
h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=bsPXMb1wc2D9mPet4PDp5QhZT95uWEB0Ew/yDrwJ3y/PH5Mtt5utgGsJnju1B3SLn
E73+1anzZ/J0qXULhuXAOhx6eSfjd8eEBEQFFH96Uhm1oNGgDQikBaLqkyzcpJT7YG
WJJqoAuLNHSgur0GLFJXbgTN8mad5aEQRnLFcu6A=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6FBB53858D37
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6FBB53858D37
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752459501; cv=none;
b=Xw5iSY3uQZ6ix7krmqgbvFfbc/bAD8lrzKwXz3+2hONZUGDjWgSe9A54UzEVKkOzgLet5u2g/iTL6j4478LfKDIQOgQ1IXL58niQXgURg5aLO4YwlQ02uhRygDj17a8VvyVMNAH/ULOwQE5V9uXqUw1Txt2Nbp49u8KSGeRcfYQ=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1752459501; c=relaxed/simple;
bh=mMEU234bGOEA0wv0Bmr3vU7fJy/ubwFGTBps2uL2+CI=;
h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature;
b=xp5ZTRsWOKb2WBS5mZwlu0tYx0vGxaKpd8agmFOh9PFaWZRH+qM9Hwntvh/JAoE60Nh+moGuwnRO0aCj94naJ4oUdXlkA6MXBO850IHVZr2pqfrC8g/0I9ihs0O49wcAtHWtdN2PesGLQdV9KiQQjDGLmNzLVzcr8i/GmJwMYKA=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FBB53858D37
Date: Mon, 14 Jul 2025 11:18:17 +0900
To: cygwin AT cygwin DOT com
Subject: Re: Problems with flushing stdin in mintty
Message-Id: <20250714111817.7afb23cd1a76e28eaf21de18@nifty.ne.jp>
In-Reply-To: <20250713203456.579fd4b87e1c2e3b560a1662@nifty.ne.jp>
References: <CAE6_+UdJmDavRc5b59yqZoKAaEGHOH1KWy+g_DNjEsi+Fs=xBw AT mail DOT gmail DOT com>
<20250713203456 DOT 579fd4b87e1c2e3b560a1662 AT nifty DOT ne DOT jp>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Takashi Yano via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

On Sun, 13 Jul 2025 20:34:56 +0900
Takashi Yano wrote:
> On Sun, 13 Jul 2025 11:40:10 +0200
> Christoph Reiter wrote:
> > I'm having the problem that under cygwin flushing stdin for some reason doesn't
> > work when running in mintty. It works when running cygwin in the Windows
> > terminal though. In my case the program using this is pacman, where it asks
> > various questions and if you hit some keys in-between questions they leak into
> > the next one, resulting in invalid input.
> > 
> > Example program showing the problem. Type some text in the first 5 seconds, and
> > see the input leak into the next input. Any ideas/workarounds welcome.
> > 
> > ```c
> > // gcc -o flush_stdin flush_stdin.c
> > #include <stdio.h>
> > #include <unistd.h>
> > #include <termios.h>
> > 
> > int main() {
> >     printf("type something in the next 5 secs\n");
> >     for (int i=0; i < 5; i++) {
> >         sleep(1);
> >         printf("%d\n", i);
> >     }
> > 
> >     // Flush stdin
> >     int fd = fileno(stdin);
> >     if (fd != -1) {
> >         printf("flushing stdin\n");
> >         if (tcflush(fd, TCIFLUSH) == -1) {  // this doesn't seem to do anything
> >             perror("Error flushing stdin");
> >             return 1;
> >         }
> >     } else {
> >         perror("Error getting file descriptor for stdin");
> >         return 1;
> >     }
> > 
> >     char buffer[100];
> >     printf("Enter some text:\n");
> >     fgets(buffer, sizeof(buffer), stdin);
> >     printf("You entered: %s\n", buffer);
> > 
> >     return 0;
> > }
> > ```
> 
> Thanks for the report.
> 
> This seems to be a bug of pty code. If you enter 'return' key
> in the first 5 sec, the input will be flushed.
> 
> I'll look into that.

Fixed.
https://cygwin.com/pipermail/cygwin-patches/2025q3/014128.html

-- 
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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