www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/07/13/07:35:29

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 56DBZSIl3138189
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 56DBZSIl3138189
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=GKRhg/12
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6B6F385840E
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1752406525;
bh=CzVsmUaF06kdVfSVwluiKSKogOmV88KuoqLfTFlb6kE=;
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=GKRhg/12SigyOJCEYgYoNH2qUPZn7lPL6VHxHozM85aDESEpSPi9XEQpwgZrLYoyV
Sr/qeVU9NduYhEMxhENvPHauapptVsUeDEkvRX64aktAQqsCGEsUlUJeu/Z4SLzz0i
3VM+fOMzBrsR3VhY1a5o6sQZ4FOxYaBnMmfTDM5Y=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A85013858C42
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A85013858C42
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752406500; cv=none;
b=xWcO/lZNHhV6yMPmleV8sG+bpjrXukBgZQsur8rHd/U3Kk7TMKVQm5uRANUbkAbqJ1xb/tHa95dGD6oHaUCeZ/B4srMjuLY3mRt1oYNI7SCkak0NX4f5uo1We8ZnAG5BrHNJ6r9tMcvvgsZh9XIlbLSG2fuvZInpPgbZxRXgV+I=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1752406500; c=relaxed/simple;
bh=u2UPphW+pBF/qFOmRtO1wE6/OqbYEHoWwo0enwy9z58=;
h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature;
b=uwBDnmaGaBNTeq2IEsjs/sS4M5dRCcAazSgVOvAOjyBaDJJ22vwRInuJMSSlDFLBtLOGds3fFA3ub8ZBKi6mZdu6IBJmGpLgvTRJzWUn5u1R0kLMFqHcUa7K+ZJmyAYUPfHgZq568O2iLEeQDHsZnP5iN0J2dbCPXaMFcUqGLlg=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A85013858C42
Date: Sun, 13 Jul 2025 20:34:56 +0900
To: cygwin AT cygwin DOT com
Subject: Re: Problems with flushing stdin in mintty
Message-Id: <20250713203456.579fd4b87e1c2e3b560a1662@nifty.ne.jp>
In-Reply-To: <CAE6_+UdJmDavRc5b59yqZoKAaEGHOH1KWy+g_DNjEsi+Fs=xBw@mail.gmail.com>
References: <CAE6_+UdJmDavRc5b59yqZoKAaEGHOH1KWy+g_DNjEsi+Fs=xBw AT mail DOT gmail DOT com>
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 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.

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