43b7806
diff -up texinfo-6.1/install-info/install-info.c.orig texinfo-6.1/install-info/install-info.c
43b7806
--- texinfo-6.1/install-info/install-info.c.orig	2016-06-22 09:49:38.766013018 +0200
43b7806
+++ texinfo-6.1/install-info/install-info.c	2016-06-22 14:11:58.673780736 +0200
43b7806
@@ -973,18 +973,23 @@ output_dirfile (char *dirfile, int dir_n
43b7806
   int n_entries_added = 0;
43b7806
   int i;
43b7806
   FILE *output;
43b7806
+  char *dirfile_tmp = NULL;
43b7806
+
43b7806
+  asprintf (&dirfile_tmp, "%s.tmp", dirfile);
43b7806
+  if (!dirfile_tmp)
43b7806
+    xalloc_die ();
43b7806
 
43b7806
   if (compression_program)
43b7806
     {
43b7806
-      char *command = concat (compression_program, ">", dirfile);
43b7806
+      char *command = concat (compression_program, ">", dirfile_tmp);
43b7806
       output = popen (command, "w");
43b7806
     }
43b7806
   else
43b7806
-    output = fopen (dirfile, "w");
43b7806
+    output = fopen (dirfile_tmp, "w");
43b7806
 
43b7806
   if (!output)
43b7806
     {
43b7806
-      perror (dirfile);
43b7806
+      perror (dirfile_tmp);
43b7806
       exit (EXIT_FAILURE);
43b7806
     }
43b7806
 
43b7806
@@ -1095,6 +1100,13 @@ output_dirfile (char *dirfile, int dir_n
43b7806
     pclose (output);
43b7806
   else
43b7806
     fclose (output);
43b7806
+
43b7806
+  if (rename (dirfile_tmp, dirfile) < 0)
43b7806
+    {
43b7806
+      perror (dirfile_tmp);
43b7806
+      exit (EXIT_FAILURE);
43b7806
+    }
43b7806
+  free (dirfile_tmp);
43b7806
 }
43b7806
 
43b7806
 /* Read through the input LINES, to find the section names and the