bin/96677: Improvements for src/tools/tools/recoverdisk

Maxim Konovalov maxim at macomnet.ru
Wed May 3 20:50:45 UTC 2006


The following reply was made to PR bin/96677; it has been noted by GNATS.

From: Maxim Konovalov <maxim at macomnet.ru>
To: Ulrich Spoerlein <uspoerlein at gmail.com>
Cc: bug-followup at 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


More information about the freebsd-bugs mailing list