www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/07/13/05:41:26

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 56D9fQ3a3017695
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 56D9fQ3a3017695
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=d3+y/GxV
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 667E33858427
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1752399683;
bh=dzwJ7nCmpkX7SlYNmdShULht3L10+ka1XuIqIAFstAw=;
h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=d3+y/GxVzVjdb4BEQ4gvXQ9Rx2xbK4RMBel8uxonFZf+QNyueihF4h9+1TlFMY2i0
3wBLDFDIJqCsIG8H5pLcxF/LV2Jj1L/htvP8tXhBvO299NJiog2ve89qYeYyy9w7sH
X3QeDL8cS09j0rmMAsr2mspxJa6Nwnd0GnUCS+w4=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA4B83858C42
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BA4B83858C42
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752399621; cv=none;
b=Z4i/x3Y+rfaqiaJw8v1ITB6FxXmMYAVAmqh2w/xzT3y/PlnObqAUQmCVNQhUY582w58FevJ5SgwC1aC+10NbWTaHhuDnOVTWa3BxbavsGKoiKeEc+6yeJmWrITBlPgkaPjWIryF3i5RALtR6Ow2tlw3pSOJ3o3WKUzwT5afM/JU=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1752399621; c=relaxed/simple;
bh=aSsvRoucCIbZ1DJ2XhI9c4QeYhMpCylRXNK/TvNvTF4=;
h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;
b=JQJdzqLgoI7yC+5YjbDULPE5S0G110VnsZVx/RhHUZJGfkz1TJIGQpoD81JgSvxWzc3Kx5S6G2wEKPlQZbxLFQIEOwfiu8uzz9Kg0/AwxskGT/cAB53hH2PkifmSu3eT5gN0i1ggkH2Rk+asM/WTPHE7Ac4S+RiRZENXDYYvBBc=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA4B83858C42
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1752399621; x=1753004421;
h=to:subject:message-id:date:from:mime-version:x-gm-message-state
:from:to:cc:subject:date:message-id:reply-to;
bh=9b+c4B/IsufqKVWW0ke0fdrYTXQJZ+QGGj9mmsc0Ex0=;
b=gpmE0gusBMYm84gteZ28iCU7acdqk5DkBM/jRGoOAoL/+vDavhbsBeGOtsa1b/Huwh
6zEnEliNj16/MTzizDAegNx0rfLnMoWdwfm0CTuLnG5VB5WwW+0SOXM5G+d2LwiXNl5f
C5X1UANn1vTZZSZDuQ4IwGquMVIlwsFDCZtqplqQQPWPMU7A9spt8Gt0QPR34+7jKyYO
QBVw2wrJg3vN9p1oEiAXnUiiOb0IpocI1e2cUP48g2dhST/7HlcBstmgKKSuD5cw4Y4w
EmtqlLmPBJ3rf7XaxWeId44U/f3hJ3CxXu4a5xN1xYqzUWdUvJuQIWNP66BuWGNhT9HM
dvLg==
X-Gm-Message-State: AOJu0Yz74MKMixook0njAwVOqFdOvxtj7pjXPJyay+CucqGwoFGxq+cc
wuwbPs2gfe8LwwakQLFguoaXuT/oSzeOuDk/qA1ExCEsrAnChgNFYYJLPpcktuN3g5A2ChJHuh2
w5Z76EgfoB66t8NOKvFxnta7OkeJ5OCZpT+zK
X-Gm-Gg: ASbGnct2RXeMcoVy26FQ6DWJDyqqMPA7gYGUxyw+24+I0Oez76J8/WiVVok52DNHoLh
rJFF77mhh8s5XarSjqNHlDCsc6grpSNQoyaq6nck74+fVgK0z7yiIzzFVPAUPuWcISY7qodZLn5
/k9yfNmTJC7bY4IJTipXnudRp1f2jofZ/e/F1FsOjvcZLGGmmAC5phTUmoV3E3UFXcb8Epf87Bp
M1BHpY=
X-Google-Smtp-Source: AGHT+IGML5wt5NHQl2fGn1NFrx1jeU6rmzHW6u0DVyQC6G2Mqg08UnuTGmJ50DdOjoCeO2uj+9bhWyoXrcBczPqW6uA=
X-Received: by 2002:a17:90b:3d10:b0:2f8:34df:5652 with SMTP id
98e67ed59e1d1-31c50e1737bmr12120219a91.21.1752399620619; Sun, 13 Jul 2025
02:40:20 -0700 (PDT)
MIME-Version: 1.0
Date: Sun, 13 Jul 2025 11:40:10 +0200
X-Gm-Features: Ac12FXyN68X3WAQHf9hZpABzHtCC-138cgQLYOOdR34TRZnH3JSFGKjUzTIVw44
Message-ID: <CAE6_+UdJmDavRc5b59yqZoKAaEGHOH1KWy+g_DNjEsi+Fs=xBw@mail.gmail.com>
Subject: Problems with flushing stdin in mintty
To: cygwin AT cygwin DOT com
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-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: Christoph Reiter via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Christoph Reiter <reiter DOT christoph AT gmail DOT com>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

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

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