Blame SOURCES/patch-2.7.6-abort_when_cleaning_up_fails.patch

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