Date: Fri, 9 Jun 2023 00:36:42 +0200 From: "Dr. Nikolaus Klepp" <dr.klepp@gmx.at> To: questions@freebsd.org Subject: Re: Slightly OT: non-buffered stdin in Java Message-ID: <202306090036.42118.dr.klepp@gmx.at> In-Reply-To: <CAGBxaXnq%2BU9C7=Vepc4Poq8LaZCo8DnkPpMH5UT70dUsKrG3bw@mail.gmail.com> References: <CAGBxaX=muu6JbMsdZbop7mYa-LetXPHvO8_=kMZtF%2BzSAdiBYA@mail.gmail.com> <202306082039.36831.dr.klepp@gmx.at> <CAGBxaXnq%2BU9C7=Vepc4Poq8LaZCo8DnkPpMH5UT70dUsKrG3bw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Anno domini 2023 Thu, 8 Jun 17:22:38 -0400 Aryeh Friedman scripsit: > On Thu, Jun 8, 2023 at 2:39=E2=80=AFPM Dr. Nikolaus Klepp <dr.klepp@gmx.a= t> wrote: > > > > Anno domini 2023 Thu, 8 Jun 14:01:19 -0400 > > Aryeh Friedman scripsit: > > > Under Java stdin (System.in) is a buffered stream not sent to the > > > application until return is pressed. But, Java can read from > > > files/sockets and other generic InputStreams unbuffered. So I was > > > wondering if there is a command that will make stdin go to a file so > > > that Java can open that file and read it unbuffered? > > > > > > I know I can do something like cat ->file but that makes it hard to > > > sync stdout and stderr (both are unbuffered in Java) with the file > > > version of stdin > > > > > > > "stdbuf" might be what you look for: > > > > https://man.freebsd.org/cgi/man.cgi?query=3Dstdbuf >=20 > Will likely need to play with it more but stdbuf -i 0 -o 0 cat -|cat > didn't produce the expected immediate echo I still had to hit return >=20 Your console is linebuffered, so "cat" receives lines. IIRC "cat" disables = linebuffer on input by itself, so you should use someting else for testing. Nik =2D-=20 Please do not email me anything that you are not comfortable also sharing w= ith the NSA, CIA ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202306090036.42118.dr.klepp>