Date: Wed, 3 May 2006 20:50:25 GMT From: Maxim Konovalov <maxim@macomnet.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/96677: Improvements for src/tools/tools/recoverdisk Message-ID: <200605032050.k43KoPl7093758@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/96677; it has been noted by GNATS. From: Maxim Konovalov <maxim@macomnet.ru> To: Ulrich Spoerlein <uspoerlein@gmail.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605032050.k43KoPl7093758>