From owner-svn-src-all@FreeBSD.ORG Mon May 10 02:07:58 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 452BF106564A; Mon, 10 May 2010 02:07:58 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id E8BF78FC08; Mon, 10 May 2010 02:07:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o4A27vPb012653; Mon, 10 May 2010 02:07:57 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4A27vUW012650; Mon, 10 May 2010 02:07:57 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201005100207.o4A27vUW012650@svn.freebsd.org> From: Xin LI Date: Mon, 10 May 2010 02:07:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207838 - stable/8/usr.bin/gzip X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2010 02:07:58 -0000 Author: delphij Date: Mon May 10 02:07:57 2010 New Revision: 207838 URL: http://svn.freebsd.org/changeset/base/207838 Log: MFC r207247,r207283,207284: - Add a signal handler for SIGINT which removes output file when necessary. - While I'm there, move unlink_input() slightly down to after closing the output file, in uncompression path. - Language improvements to make the BUGS section easier to read. Modified: stable/8/usr.bin/gzip/gzip.1 stable/8/usr.bin/gzip/gzip.c Directory Properties: stable/8/usr.bin/gzip/ (props changed) Modified: stable/8/usr.bin/gzip/gzip.1 ============================================================================== --- stable/8/usr.bin/gzip/gzip.1 Mon May 10 02:07:42 2010 (r207837) +++ stable/8/usr.bin/gzip/gzip.1 Mon May 10 02:07:57 2010 (r207838) @@ -25,7 +25,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd April 7, 2010 +.Dd April 27, 2010 .Dt GZIP 1 .Os .Sh NAME @@ -218,8 +218,8 @@ with unpack support written by .An Xin LI Aq delphij@FreeBSD.org . .Sh BUGS According to RFC 1952, the recorded file size is stored in a 32-bit -integer and therefore it can not represent files that is bigger than -4GB in size. This limitation also applies to +integer, therefore, it can not represent files larger than 4GB. +This limitation also applies to .Fl l option of .Nm Modified: stable/8/usr.bin/gzip/gzip.c ============================================================================== --- stable/8/usr.bin/gzip/gzip.c Mon May 10 02:07:42 2010 (r207837) +++ stable/8/usr.bin/gzip/gzip.c Mon May 10 02:07:57 2010 (r207838) @@ -43,7 +43,6 @@ __RCSID("$FreeBSD$"); * * TODO: * - use mmap where possible - * - handle some signals better (remove outfile?) * - make bzip2/compress -v/-t/-l support work as well as possible */ @@ -194,6 +193,7 @@ static int qflag; /* quiet mode */ static int rflag; /* recursive mode */ static int tflag; /* test */ static int vflag; /* verbose mode */ +static const char *remove_file = NULL; /* file to be removed upon SIGINT */ #else #define qflag 0 #define tflag 0 @@ -231,6 +231,7 @@ static void usage(void); static void display_version(void); #ifndef SMALL static void display_license(void); +static void sigint_handler(int); #endif static const suffixes_t *check_suffix(char *, int); static ssize_t read_retry(int, void *, size_t); @@ -300,11 +301,10 @@ main(int argc, char **argv) #endif int ch; - /* XXX set up signals */ - #ifndef SMALL if ((gzip = getenv("GZIP")) != NULL) prepend_gzip(gzip, &argc, &argv); + signal(SIGINT, sigint_handler); #endif /* @@ -1171,6 +1171,15 @@ unlink_input(const char *file, const str return; unlink(file); } + +static void +sigint_handler(int signo __unused) +{ + + if (remove_file != NULL) + unlink(remove_file); + _exit(2); +} #endif static const suffixes_t * @@ -1257,6 +1266,9 @@ file_compress(char *file, char *outfile, fclose(stdin); return -1; } +#ifndef SMALL + remove_file = outfile; +#endif } else out = STDOUT_FILENO; @@ -1288,6 +1300,7 @@ file_compress(char *file, char *outfile, } copymodes(out, &isb, outfile); + remove_file = NULL; #endif if (close(out) == -1) maybe_warn("couldn't close output"); @@ -1424,6 +1437,9 @@ file_uncompress(char *file, char *outfil maybe_warn("can't open %s", outfile); goto lose; } +#ifndef SMALL + remove_file = outfile; +#endif } else zfd = STDOUT_FILENO; @@ -1555,11 +1571,12 @@ file_uncompress(char *file, char *outfil unlink(outfile); return -1; } - unlink_input(file, &isb); #ifndef SMALL copymodes(ofd, &isb, outfile); + remove_file = NULL; #endif close(ofd); + unlink_input(file, &isb); return size; unexpected_EOF: