Cannot call @system funciton (stdout)
snarwin at gmail.com
Sat Sep 19 14:14:46 UTC 2020
On Saturday, 19 September 2020 at 13:56:53 UTC, Anonymouse wrote:
> On Saturday, 19 September 2020 at 13:32:07 UTC, Paul Backus
> I don't have a clone of druntime/Phobos available to me right
> now, so some follow-up questions.
> It looks like full buffering _IOFBF is the default setting, but
> "normal" non-Cygwin stdio certainly seems to do line buffering.
> Is it getting set to line buffering _IOLBF during
> initialisation of stdout? (Why then is Cygwin exempt?)
This isn't a druntime/Phobos thing, it's a libc thing. Phobos
just provides a wrapper around it.
My guess is that libc uses something like `isatty(STDOUT_FILENO)`
to determine if it should use line buffering, and that there's a
bug in Cygwin that causes isatty() to always return false. If you
want to know for sure, you can try looking through the Cygwin
source code. 
> Is there a way to detect programmatically if I'm in an
> environment where I need to manually set line buffering?
You can check the TERM environment variable , or you can use
the POSIX uname() function  to see if you're running under
Cygwin specifically. If there are any other environments where
you need to manually set line-buffering, you'll probably have to
check for those individually as well.
More information about the Digitalmars-d-learn