Fix races with threads and file descriptors.
[bpt/emacs.git] / src / unexaix.c
index 204f6cf..45b3ca6 100644 (file)
@@ -97,7 +97,7 @@ report_error (const char *file, int fd)
   if (fd)
     {
       int failed_errno = errno;
-      close (fd);
+      emacs_close (fd);
       errno = failed_errno;
     }
   report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
@@ -111,7 +111,7 @@ static _Noreturn void ATTRIBUTE_FORMAT_PRINTF (2, 3)
 report_error_1 (int fd, const char *msg, ...)
 {
   va_list ap;
-  close (fd);
+  emacs_close (fd);
   va_start (ap, msg);
   verror (msg, ap);
   va_end (ap);
@@ -148,13 +148,13 @@ unexec (const char *new_name, const char *a_name)
       || adjust_lnnoptrs (new, a_out, new_name) < 0
       || unrelocate_symbols (new, a_out, a_name, new_name) < 0)
     {
-      close (new);
+      emacs_close (new);
       return;
     }
 
-  close (new);
+  emacs_close (new);
   if (a_out >= 0)
-    close (a_out);
+    emacs_close (a_out);
   mark_x (new_name);
 }
 
@@ -534,7 +534,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
             }
        }
     }
-  close (new);
+  emacs_close (new);
 
   return 0;
 }