Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: "Thomas Hammer" To: , Cc: Subject: Bug in gzip's stdout handling Date: Fri, 14 Nov 2003 10:37:07 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal Hi. I run the latest version of cygwin, with gzip, on WindowsXP SP1 and have a problem with gzip. The command $ cat binaryfile.bin | gzip -c > bin.gz produces an invalid .gz file: $ gunzip bin.gz gunzip: bin.gz: invalid compressed data--crc error gunzip: bin.gz: invalid compressed data--length error If I do gzip binaryfile.bin everything works as expected - i.e. the resulting .gz file is valid. If I do this instead: cat binaryfile.bin > acopy.bin The two .bin files are identical. My gzip version: $ gzip --version gzip 1.3.5 (2002-09-30) Copyright 2002 Free Software Foundation Copyright 1992-1993 Jean-loup Gailly This program comes with ABSOLUTELY NO WARRANTY. You may redistribute copies of this program under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING. Compilation options: DIRENT UTIME STDC_HEADERS HAVE_UNISTD_H HAVE_MEMORY_H HAVE_STRING_H HAVE_LSTAT ASMV Written by Jean-loup Gailly. My conclusion is that gzip's handling of stdout is broken in some way. The reason I report this problem, instead of just avoiding it by not using the -c option for gzip, is that I discovered the problem while running make dist on a Makefile.in created by automake. And it's automake that creates the gzip command line. I'll send a patch to the automake people and ask them to fix this - but since it's really gzip that is broken, I think it should be fixed here too. I think you could fix this by setting the mode for the filehandle for stdout to O_BINARY, i.e. something like this: #if defined (_WIN32) setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ #endif It would be nice if you could look into it. Best Regards, Thomas Hammer hammer AT sim DOT no -- 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/