|
|
548ccd |
commit b7b028a77bd855f6f56b17c8837fc1cca77b469d
|
|
|
548ccd |
Author: Andreas Gruenbacher <agruen@gnu.org>
|
|
|
548ccd |
Date: Fri Jun 28 00:30:25 2019 +0200
|
|
|
548ccd |
|
|
|
548ccd |
Abort when cleaning up fails
|
|
|
548ccd |
|
|
|
548ccd |
When a fatal error triggers during cleanup, another attempt will be made to
|
|
|
548ccd |
clean up, which will likely lead to the same fatal error. So instead, bail out
|
|
|
548ccd |
when that happens.
|
|
|
548ccd |
src/patch.c (cleanup): Bail out when called recursively.
|
|
|
548ccd |
(main): There is no need to call output_files() before cleanup() as cleanup()
|
|
|
548ccd |
already does that.
|
|
|
548ccd |
|
|
|
548ccd |
diff --git a/src/patch.c b/src/patch.c
|
|
|
548ccd |
index 4616a48..02fd982 100644
|
|
|
548ccd |
--- a/src/patch.c
|
|
|
548ccd |
+++ b/src/patch.c
|
|
|
548ccd |
@@ -685,7 +685,6 @@ main (int argc, char **argv)
|
|
|
548ccd |
}
|
|
|
548ccd |
if (outstate.ofp && (ferror (outstate.ofp) || fclose (outstate.ofp) != 0))
|
|
|
548ccd |
write_fatal ();
|
|
|
548ccd |
- output_files (NULL);
|
|
|
548ccd |
cleanup ();
|
|
|
548ccd |
delete_files ();
|
|
|
548ccd |
if (somefailed)
|
|
|
548ccd |
@@ -1991,7 +1990,6 @@ void
|
|
|
548ccd |
fatal_exit (int sig)
|
|
|
548ccd |
{
|
|
|
548ccd |
cleanup ();
|
|
|
548ccd |
-
|
|
|
548ccd |
if (sig)
|
|
|
548ccd |
exit_with_signal (sig);
|
|
|
548ccd |
|
|
|
548ccd |
@@ -2011,6 +2009,12 @@ remove_if_needed (char const *name, bool *needs_removal)
|
|
|
548ccd |
static void
|
|
|
548ccd |
cleanup (void)
|
|
|
548ccd |
{
|
|
|
548ccd |
+ static bool already_cleaning_up;
|
|
|
548ccd |
+
|
|
|
548ccd |
+ if (already_cleaning_up)
|
|
|
548ccd |
+ return;
|
|
|
548ccd |
+ already_cleaning_up = true;
|
|
|
548ccd |
+
|
|
|
548ccd |
remove_if_needed (TMPINNAME, &TMPINNAME_needs_removal);
|
|
|
548ccd |
remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal);
|
|
|
548ccd |
remove_if_needed (TMPPATNAME, &TMPPATNAME_needs_removal);
|