Re: [PATCH 0/4] Cross compiling sharutils

Eric Blake <[email protected]> Thu, 21 May 2015 08:40:29 -0600
Newsgroups gmane.comp.gnu.utils.bugs
Organization Red Hat, Inc.
Message-ID <[email protected]>
On 05/20/2015 10:40 PM, Filipe Brandenburger wrote:

> Looking at the cygwin popen implementation (assuming I have the right
> one), it doesn't really look like they look for a 'b' and handle that
> any differently:
> 
> https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/posix/popen.c;h=faf72b6e380a8f74cc6af590a540b9fe292aab28;hb=HEAD#l120

Wrong source.  That's the generic newlib implementation of popen, but
cygwin overrides with its own version at:

https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/syscalls.cc;h=86faa3;hb=HEAD#l4297

which indeed treats "rb" differently from "r" and the extension "rt".

> 
> So I'm really at a loss at why this code was even there, as I can't
> really think of another platform that would conceivably handle
> popen("rb") different from popen("r") if cygwin doesn't...

But cygwin DOES care about "rb"; if you don't pass the 'b', then you
risk \r being unexpectedly stripped from the command's output.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc (application/pgp-signature, 604 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCAAGBQJVXe5dAAoJEKeha0olJ0Nqyw0H/3Z5Qh4aSp1XdcImkJzYR4YV
bhf6/0E46DkAfhpVE/iQQwVsAuX8pzpmMoS/m+c4YmLAqpuNoAKp0Qlgwl6t4tv5
PJ8hgAcwH3nPY+QAf+0iX7lynUeF7gJtee7x8SeSE3mLma5wDpic8gXCsNnz2vyT
59XLKYqpa95A3BKdJKdcA+YV1giMavBudMvM4/cGVtBIYPosopnUGeHQtMmzgeOJ
+movwQpxFg7lf576sG/xMNfi1ajRo/Zl26enzDOBSMGc+zZS4UU62NlMMNM8ei8n
wr9X/jQFopyJ4i34e+SSaRcmWrltceW0QOWNkFy2fhkzVBz0+VdCgZNKg//7MfI=
=NEcT
-----END PGP SIGNATURE-----