From owner-svn-src-head@FreeBSD.ORG Tue Aug 25 06:21:46 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 516E6106568C; Tue, 25 Aug 2009 06:21:46 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 411A28FC21; Tue, 25 Aug 2009 06:21:46 +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 n7P6Lj4b018041; Tue, 25 Aug 2009 06:21:45 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7P6LjKQ018039; Tue, 25 Aug 2009 06:21:45 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200908250621.n7P6LjKQ018039@svn.freebsd.org> From: Ulf Lilleengen Date: Tue, 25 Aug 2009 06:21:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196528 - head/sbin/savecore X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2009 06:21:46 -0000 Author: lulf Date: Tue Aug 25 06:21:45 2009 New Revision: 196528 URL: http://svn.freebsd.org/changeset/base/196528 Log: - Add a SIGINFO handler for savecore. Modified: head/sbin/savecore/savecore.c Modified: head/sbin/savecore/savecore.c ============================================================================== --- head/sbin/savecore/savecore.c Tue Aug 25 04:09:09 2009 (r196527) +++ head/sbin/savecore/savecore.c Tue Aug 25 06:21:45 2009 (r196528) @@ -97,6 +97,9 @@ static int nfound, nsaved, nerr; /* st extern FILE *zopen(const char *, const char *); +static sig_atomic_t got_siginfo; +static void infohandler(int); + static void printheader(FILE *f, const struct kerneldumpheader *h, const char *device, int bounds, const int status) @@ -231,9 +234,10 @@ DoRegularFile(int fd, off_t dumpsize, ch const char *filename, FILE *fp) { int he, hs, nr, nw, wl; - off_t dmpcnt; + off_t dmpcnt, origsize; dmpcnt = 0; + origsize = dumpsize; he = 0; while (dumpsize > 0) { wl = BUFFERSIZE; @@ -304,6 +308,11 @@ DoRegularFile(int fd, off_t dumpsize, ch fflush(stdout); } dumpsize -= wl; + if (got_siginfo) { + printf("%s %.1lf%%\n", filename, (100.0 - (100.0 * + (double)dumpsize / (double)origsize))); + got_siginfo = 0; + } } return (0); } @@ -648,6 +657,7 @@ main(int argc, char **argv) nfound = nsaved = nerr = 0; openlog("savecore", LOG_PERROR, LOG_DAEMON); + signal(SIGINFO, infohandler); while ((ch = getopt(argc, argv, "Ccfkvz")) != -1) switch(ch) { @@ -719,3 +729,9 @@ main(int argc, char **argv) return (0); } + +static void +infohandler(int sig __unused) +{ + got_siginfo = 1; +}