From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14779 invoked by alias); 18 Jan 2009 21:42:39 -0000 Received: (qmail 14769 invoked by uid 22791); 18 Jan 2009 21:42:38 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-ew0-f11.google.com (HELO mail-ew0-f11.google.com) (209.85.219.11) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Jan 2009 21:42:34 +0000 Received: by ewy4 with SMTP id 4so706351ewy.2 for ; Sun, 18 Jan 2009 13:42:31 -0800 (PST) Received: by 10.210.67.4 with SMTP id p4mr4967755eba.116.1232314950283; Sun, 18 Jan 2009 13:42:30 -0800 (PST) Received: by 10.210.81.20 with HTTP; Sun, 18 Jan 2009 13:42:30 -0800 (PST) Message-ID: <2ca21dcc0901181342p5d565f2bhdabf09ed769b427b@mail.gmail.com> Date: Sun, 18 Jan 2009 22:19:00 -0000 From: "Dave Korn" To: cygwin@cygwin.com Subject: Re: GNU coreutils does not work on Cygwin because of freopen() ? In-Reply-To: <49739071.8030307@dazjorz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <49739071.8030307@dazjorz.com> Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2009-01/txt/msg00553.txt.bz2 dazjorz wrote: > - Cygwin didn't have md5sum, Cygwin does have md5sum in coreutils. You can see this at the cygwin package list: http://cygwin.com/packages/ by entering 'md5sum.exe' in the search box. > - It should work, and "Because I Can" is always a valid reason in UNIX > world However, you may have to recreate all the cygwin-specific patches that the cygwin bash maintainer hasn't managed to send upstream yet... > - I'm trying to bootstrap Debian on Cygwin, and coreutils from Debian is > my first try; getting coreutils from Cygwin may be done later. Dunno if your project makes sense. You'll have to end up porting everything where the differences in the underlying OS show through... which is basically what Cygwin package maintainers have already done for most of this stuff. Do you mean you're trying to cross-compile Debian on Cygwin, or do you actually want to build the whole Debian distro under Cygwin to run on Windows rather than natively under a linux kernel? > However, I noticed there are some very weird bugs happening. See for > example, this bug in cat (don't look at the title of the page, I blamed > bash first) > http://paster.dazjorz.com/?p=3845 > > A friend of mine and me have been trying to figure out what causes this. > First, we tested if it wasn't a bug in open() + fork(). This seemed not > to be the case. So we started looking further, and we're down to GNU > `cat` calling freopen(). This is not POSIX-compliant and can cause > problems like this. ?? Are you using an old version?? It should be fixed by now. http://www.mail-archive.com/bug-coreutils@gnu.org/msg10188.html > `cat` and other coreutils tools only call freopen() if O_BINARY is > defined on this platform. It's defined on Cygwin, because Cygwin makes a > difference between O_TEXT and O_BINARY. > > 1. Why does Cygwin distinguish between O_TEXT and O_BINARY? Shouldn't > this difference be removed from the Linux API side of Cygwin? Nope. Cygwin runs on windows, which uses CR-LF for line endings, but Cygwin is POSIX-compliant and uses LF internally. This is exactly what O_TEXT was invented for: it translates LF->CRLF on write and CRLF->LF on read. On Linux platforms, the native format is LF line-ends, so O_TEXT and O_BINARY are the same, but not here. > 2. I don't know why coreutils is calling freopen() at all. Should I > patch it out completely, or add something like an #ifndef __CYGWIN__ > around the pieces of code in question? Well, if you really want to build coreutils under cygwin, why not use setup.exe to install the corresponding source package, which comes with all these problems pre-solved for you? cheers, DaveK -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/