Blame SOURCES/patch-2.7.x-abort_when_cleaning_up_fails.patch

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