Subject: Re: file descriptors opened as text files
From: Ross Smith <[email-masked]>
To: [email-masked]
Date: Thu, 15 Feb 2001 13:52:31 +1300

"Larry Hall (RFK Partners Inc)" wrote:
> 
> At 05:43 PM 2/14/01, Jean Delvare wrote:
> 
> >That may explain why I could not see the flag on linux's man pages. But
> >there is no man page for open(2) on Cygwin, right ? Then, where am I
> >supposed to find the value for this flag, if it ever exist ? I can't just
> >invent it, I guess it won't work ;)
> 
> "b" is fine, as you indicated before.  Check the MSDN library at
> msdn.microsoft.com for one source.  I'm sure you can find this information
> in any POSIX complaint UNIX API reference.

Possibly not. I don't have a copy of the relevant Posix standard, but
the Single Unix Standard (which I believe is intended to be a superset
of Posix) doesn't recognise the binary/text mode distinction.

However, the C standard mandates that fopen() uses text mode by default
in the absence of the "b" flag, and the C++ standard says the same thing
about iostreams. So, given that the two higher-level I/O APIs are both
required to default to text mode, it seems perfectly reasonable to me
for the lowest-level one, open(), to do the same thing in the absence of
any standard requirements, and it looks as though the Cygwin designers
have followed the same reasoning.

There's no standard way to select the mode for open(), but Cygwin
provides the non-standard one O_TEXT. Include it in your open mode flags
(second argument to open()).

-- 
Ross Smith <[email-masked]> The Internet Group, Auckland, New Zealand
========================================================================
          "Normally he was insane, but he had lucid moments
          when he was merely stupid."     -- Heinrich Heine

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple