From owner-freebsd-bugs@FreeBSD.ORG Wed May 3 20:50:45 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 250EB16A491 for ; Wed, 3 May 2006 20:50:45 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC21F43D46 for ; Wed, 3 May 2006 20:50:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k43KoPSv093759 for ; Wed, 3 May 2006 20:50:25 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k43KoPl7093758; Wed, 3 May 2006 20:50:25 GMT (envelope-from gnats) Date: Wed, 3 May 2006 20:50:25 GMT Message-Id: <200605032050.k43KoPl7093758@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Maxim Konovalov Cc: Subject: Re: bin/96677: Improvements for src/tools/tools/recoverdisk X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Maxim Konovalov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 May 2006 20:50:45 -0000 The following reply was made to PR bin/96677; it has been noted by GNATS. From: Maxim Konovalov To: Ulrich Spoerlein Cc: bug-followup@freebsd.org Subject: Re: bin/96677: Improvements for src/tools/tools/recoverdisk Date: Thu, 4 May 2006 00:47:42 +0400 (MSD) Hi Ulrich, [...] > +static void > +save_worklist(__unused int sig) > +{ > + FILE *file; > + > + if (wworklist != NULL) { > + (void)fprintf(stderr, "\nSaving worklist ..."); > + fflush(stderr); > + > + file = fopen(wworklist, "w"); > + if (file == NULL) > + err(1, "Error opening file %s", wworklist); > + > + for (;;) { > + lp = TAILQ_FIRST(&lumps); > + if (lp == NULL) > + break; > + fprintf(file, "%jd %jd %d\n", > + (intmax_t)lp->start, (intmax_t)lp->len, lp->state); > + TAILQ_REMOVE(&lumps, lp, list); > + } > + (void)fprintf(stderr, " done.\n"); > + } > + exit(0); > +} [...] In general, you can't use signal unsafe functions (e.g. all stdio(3) functions) in the signal handlers. Manupulation with unprotected data in the signal handler is unsafe too. See Bruce's followup to bin/78304 for some useful info about signal handlers: http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/78304 -- Maxim Konovalov