delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/10/29/12:53:04

X-Spam-Check-By: sourceware.org
Date: Sun, 29 Oct 2006 09:52:23 -0800
From: Bart Schaefer <schaefer AT brasslantern DOT com>
Subject: Re: gunzip 1.3.5 error reading from stdin on Cygwin
In-reply-to: <20a807210610290514k7f17abdfja21c611b45ff468b@mail.gmail.com>
To: "Vin Shelton" <acs AT alumni DOT princeton DOT edu>, cygwin AT cygwin DOT com
Cc: zsh-workers AT sunsite DOT dk
Message-id: <061029095227.ZM8389@torch.brasslantern.com>
MIME-version: 1.0
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
References: <20a807210610290514k7f17abdfja21c611b45ff468b AT mail DOT gmail DOT com>
Comments: In reply to "Vin Shelton" <acs AT alumni DOT princeton DOT edu> "Re: gunzip 1.3.5 error reading from stdin on Cygwin" (Oct 29, 5:14am)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Oct 29,  5:14am, Vin Shelton wrote:
} Subject: Re: gunzip 1.3.5 error reading from stdin on Cygwin
}
} I've narrowed this down a little bit.  It only happens under zsh;
} under bash, the recipe works without error.

In zsh's main.c is this comment:

 * Cygwin supports the notion of binary or text mode access to files
 * based on the mount attributes of the filesystem.  If a file is on
 * a binary mounted filesystem, you get exactly what's in the file, CRLF's
 * and all.  If it's on a text mounted filesystem, Cygwin will strip out
 * the CRs.  This presents a problem because zsh code doesn't allow for
 * CRLF's as line terminators.  So, we must force all open files to be
 * in text mode reguardless of the underlying filesystem attributes.
 * However, we only want to do this for reading, not writing as we still
 * want to write files in the mode of the filesystem.  To do this,
 * we have two options: augment all {f}open() calls to have O_TEXT added to
 * the list of file mode options, or have the Cygwin runtime do it for us.
 * I choose the latter. :)
 *
 * Cygwin's runtime provides pre-execution hooks which allow you to set
 * various attributes for the process which effect how the process functions.
 * One of these attributes controls how files are opened.  I've set
 * it up so that all files opened RDONLY will have the O_TEXT option set,
 * thus forcing line termination manipulation.  This seems to solve the
 * problem (at least the Test suite runs clean :).
 *
 * Note: this may not work in later implementations.  This will override
 * all mode options passed into open().  Cygwin (really Windows) doesn't
 * support all that much in options, so for now this is OK, but later on
 * it may not, in which case O_TEXT will have to be added to all opens calls
 * appropriately.

The actual code is:

    static struct __cygwin_perfile pf[] =
    {
        {"", O_RDONLY | O_TEXT},
        {NULL, 0}
    };
    cygwin_internal (CW_PERFILE, pf);

-- 

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019