public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: stty -cooked not usable since cygwin-3.1.1-1
Date: Wed, 29 Jul 2020 02:40:53 +0900	[thread overview]
Message-ID: <20200729024053.52095c2f5a8d6356d748935f@nifty.ne.jp> (raw)
In-Reply-To: <d78149b7-b4c8-5619-71ca-f3b70a04fd26@towo.net>

On Tue, 28 Jul 2020 18:56:06 +0200
Thomas Wolff wrote:
> Am 28.07.2020 um 18:38 schrieb Takashi Yano via Cygwin:
> > On Tue, 28 Jul 2020 15:56:54 +0200
> > Rabbe Fogelholm wrote:
> >> Rabbe Fogelholm wrote:
> >>> Takashi Yano wrote:
> >>>> On Mon, 13 Jan 2020 11:52:43 +0100
> >>>> Rabbe Fogelholm wrote:
> >>>>> I am running a console Java program that is started from a shellscript
> >>>>> wrapper. Before invoking Java the wrapper calls `stty -cooked'. The Java
> >>>>> program polls the keyboard using System.in.available() and reads
> >>>>> characters immediately using System.in.read(), without waiting for the
> >>>>> Enter key to be pressed.
> >>>>>
> >>>>> This way of combining `stty -cooked' and Java has stopped working since
> >>>>> version 3.1.1-1 of the Cygwin package. The Java thread that reads the
> >>>>> keyboard hangs until Enter is pressed, which is not desirable.
> >>>>>
> >>>>> I had to downgrade to version 3.0.7-1 to resolve the problem.
> >>>>>
> >>>>> Versioning information:
> >>>>>
> >>>>> java version "1.8.0_202"
> >>>>> Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
> >>>>> Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
> >>>>>
> >>>>> OS Name: Microsoft Windows 10 Pro
> >>>>> Version: 10.0.17763 Build 17763
> >>>>> System Type: x64-based PC
> >>>>>
> >>>>> See also the enclosed cygcheck.out.
> >>>>>
> >>>>> To demonstrate the issue I enclose a small Java program that should be
> >>>>> able to read single keystrokes when `stty -cooked' is in effect.
> >>>> Does your java program work in command prompt? cygwin 3.1.x uses
> >>>> pseudo console, so the native (non cygwin) program works as if it
> >>>> is executed in command prompt.
> >>>>
> >>> With cygwin 3.1.x I can't find a way to make my program work.
> >>>
> >>> When running from within a Cygwin64 terminal the `stty -cooked' command
> >>> terminates with exit code 0, but the Java program behaves just as if
> >>> `stty -cooked' is not in effect: It does not handle single keystrokes
> >>> immediately.
> >>>
> >>> When running from a Windows command prompt I can execute the stty
> >>> program as \cygwin64\bin\stty. However, when given the '-cooked'
> >>> argument it complains:
> >>> /usr/bin/stty: 'standard input': unable to perform all requested operations
> >>>
> >>> - and here as well the Java program behaves as if `stty -cooked' is not
> >>> in effect.
> >> Some time has passed; I am just curious if anyone may have found a
> >> solution to the "stty -cooked" issue. With cygwin-3.0.* it was possible
> >> to have a Java program act on single keystrokes, with cygwin-3.1 I don't
> >> know how to do it. Any ideas welcome!
> > Solution 1:
> > Redesign your java program using JNA with kbhit()/getch() instead of
> > System.in.available()/System.in.read().
> >
> > Solution 2:
> > Add SetConsoleMode() call with ENABLE_LINE_INPUT flag cleared using JNA.

I'm sorry, but this does not work as far as I tested.
I'm not sure why.

> Couldn't cygwin clear this flag when it sets up ConPTY while the pty is 
> in raw mode?

Thomas's proposal will not work as well.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

  reply	other threads:[~2020-07-28 17:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-13 10:53 Rabbe Fogelholm
2020-01-13 11:02 ` Takashi Yano
2020-01-13 11:36   ` Rabbe Fogelholm
2020-07-28 13:56     ` Rabbe Fogelholm
2020-07-28 16:38       ` Takashi Yano
2020-07-28 16:56         ` Thomas Wolff
2020-07-28 17:40           ` Takashi Yano [this message]
2020-07-28 19:51           ` Rabbe Fogelholm
2020-07-28 23:30             ` Thomas Wolff
2020-07-29 20:03               ` Rabbe Fogelholm
2020-07-31  6:52                 ` Rabbe Fogelholm
2020-07-29  0:02             ` Takashi Yano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200729024053.52095c2f5a8d6356d748935f@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).