From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13177 invoked by alias); 18 Jan 2009 20:55:44 -0000 Received: (qmail 13168 invoked by uid 22791); 18 Jan 2009 20:55:44 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from nf-out-0910.google.com (HELO nf-out-0910.google.com) (64.233.182.184) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Jan 2009 20:55:38 +0000 Received: by nf-out-0910.google.com with SMTP id b11so351843nfh.18 for ; Sun, 18 Jan 2009 12:55:34 -0800 (PST) Received: by 10.210.114.11 with SMTP id m11mr837922ebc.179.1232308332116; Sun, 18 Jan 2009 11:52:12 -0800 (PST) Received: from ?192.168.1.2? (82-171-113-142.ip.telfort.nl [82.171.113.142]) by mx.google.com with ESMTPS id b33sm6506470ika.3.2009.01.18.11.52.10 (version=SSLv3 cipher=RC4-MD5); Sun, 18 Jan 2009 11:52:11 -0800 (PST) Message-ID: <49738867.702@dazjorz.com> Date: Sun, 18 Jan 2009 21:25:00 -0000 From: dazjorz User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: cygwin@cygwin.com Subject: GNU coreutils does not work on Cygwin because of freopen() ? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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/msg00547.txt.bz2 Hey all, I'm not very great with the inner workings of GNU or Cygwin libc, so please bear with me if I make any mistakes or misunderstandings. I was trying to get GNU coreutils to work on Cygwin. Maybe this seems weird to you guys, because Cygwin has coreutils, but there are a few reasons: - Cygwin didn't have md5sum, GNU coreutils did (and I need md5sum) - It should work, and "Because I Can" is always a valid reason in UNIX world - I'm trying to bootstrap Debian on Cygwin, and coreutils from Debian is my first try; getting coreutils from Cygwin may be done later. 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. `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? 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? I'm hesitant to patch coreutils, so I'm asking for your opinion first. Thanks for any replies, Sjors -- 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/