This is the mail archive of the
mailing list for the Cygwin project.
RE: How is textmode/binmode determined in Cygwin 1.1.0 net releas e for pipes?
- To: 'David Bolen' <db3l at fitlinxx dot com>, "'cygwin at sourceware dot cygnus dot com'" <cygwin at sourceware dot cygnus dot com>
- Subject: RE: How is textmode/binmode determined in Cygwin 1.1.0 net releas e for pipes?
- From: Bernard Dautrevaux <Dautrevaux at microprocess dot com>
- Date: Fri, 28 Apr 2000 19:09:43 +0200
> -----Original Message-----
> From: David Bolen [mailto:firstname.lastname@example.org]
> Sent: Friday, April 28, 2000 7:25 AM
> To: 'email@example.com'
> Subject: RE: How is textmode/binmode determined in Cygwin 1.1.0 net
> releas e for pipes?
> As I think I mentioned in my original note, I'm using rsync,
> so the server
> side is just being spawned out of a named pipe server that
> happens to be run
> from a console window for testing purposes. It's thinking
> it's running in
> rsh mode so the server just uses stdin/stdout for the
> traffic. That's the
> So, without asking for too much specific help (treading
> cautiously here :-))
> - is it possible that line 157 in hinfo.cc should be changed from:
> int bin = __fmode;
> int bin = (__fmode ? __fmode : O_BINARY)
> in order to make the default for stdin/stdout binary even if
> CYGWIN isn't
> set? That seems to mirror the way that pipe.cc checks things
> when it's
> making the pipes.
> I haven't yet run a full build of the DLL locally, so I'll
> have to schedule
> some time tomorrow to do that to test the change locally?
> But adding a
> setmode(O_BINARY) on both stdin and stdout in the rsync code
> did resolve the
> problem without having to add the CYGWIN environment variable.
I ran in the same kind of problem some time ago (but was only reading my
mail now so was not able to provide any advice before :-|) and I solve it by
setting by default stdin as O_TEXT, and stdout as O_BINARY; only when I
*know* that I'm reading binary data from the standard input have I to set
manually stdin as O_BINARY.
The rationale is that I usually read and write text through a file, but
would rather write even text in O_BINARY mode so that others don't get
bothered by the CR/LF sequences but get simple LF line endings; however if
such a brain-damaged program pours on me CR/LFs, they are just automagically
converted for me :-)
OTOH if I'm reading binary data, I'm used to specify explicitely O_BINARY to
read files, so setting it also for pipes doesn't hurt a lot; OK I should
agree that this argument may be returned to me for the opposite setting! but
the experience shows that pipes are a lot more often conveying text, so
having O_TEXT as a default for reading on stdin seems correct more often
than being wrong.
Of course if we can persuade Micro$oft to abandon CR/LF line endings that
would be the perfect solution, but realism asks for trying to live with them
:-) so I would propose, in the absence of an explicit setting, that stdin be
read as TEXT and stdout written as BINARY. Maybe this could even be an
option in CYGWIN: "text" meaning everyting is done in TEXT mode, "binary"
everything in BINARY mode and "sane", or insane if you prefer ;-), used for
reading as TEXT and writing as BINARY.
Just my 2 cents,
97 bis, rue de Colombes
Tel: +33 (0) 1 47 68 80 80
Fax: +33 (0) 1 47 88 97 85
Want to unsubscribe from this list?
Send a message to firstname.lastname@example.org