I wrote: > The bad code is in gzip.c: > > if (!to_stdout) > { > sigset_t oldset; > int unlink_errno; > > copy_stat (&istat); > if (close (ofd) != 0) > write_error ();
However, the close will need to occur after the last file has been written to stdout, perhaps in main itself. Alternatively, you could dup stdout for each file and close the duplicate (would this work)? Regards, Giuliano Procida. -----Original Message----- From: Procida, Giuliano Sent: 27 January 2009 12:19 To: 'bug-gzip@gnu.org' Subject: possible loss of data due to missing close when --stdout in force Hi. Tested gzip 1.3.3 and 1.3.12 on Linux i386. When operating with --stdout, gzip fails to close stdout at the end of input. This can result in silent loss of data if a partition fills, with the probability of silent loss increasing as the size of file decreases. I've reported the same bug in bzip2 to the author - this one did cause me serious problems. The bad code is in gzip.c: if (!to_stdout) { sigset_t oldset; int unlink_errno; copy_stat (&istat); if (close (ofd) != 0) write_error (); sigprocmask (SIG_BLOCK, &caught_signals, &oldset); remove_ofname_fd = -1; unlink_errno = xunlink (ifname) == 0 ? 0 : errno; sigprocmask (SIG_SETMASK, &oldset, NULL); if (unlink_errno) { WARN ((stderr, "%s: ", program_name)); if (!quiet) { errno = unlink_errno; perror (ifname); } } The close and error check should happen regardless. Regards, Giuliano Procida.
Issued by UBS AG or affiliates to professional investors only. Product of a sales/trading desk and not the Research Dept. Opinions expressed may differ from those of other divisions of UBS, including Research. UBS may trade as principal in instruments identified herein and may accumulate/have accumulated a long/short position in instruments or derivatives thereof. UBS has policies designed to manage conflicts of interest. This e-mail is not an official confirmation of terms and unless stated, is not a personal recommendation, offer or solicitation to buy or sell. Any prices or quotations contained herein are indicative only and not for valuation purposes. Communications may be monitored. © UBS 2009. All rights reserved. Intended for recipient only and not for further distribution without the consent of UBS. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.