bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unlink failure on abort


From: Orgad Shaneh
Subject: Re: Unlink failure on abort
Date: Sat, 17 Jun 2017 23:04:11 +0300

On Fri, Jun 16, 2017 at 7:36 PM, Eli Zaretskii <address@hidden> wrote:
> From: Orgad Shaneh <address@hidden>
> Date: Fri, 16 Jun 2017 17:05:58 +0300
> Cc: "address@hidden" <address@hidden>, Alexey Pavlov <address@hidden>
>
>  Ah, okay. But then the problem is not with child processes of g++,
>  it's with g++ itself, right?
>
> The child process cc1plus has the file open for writing, and g++ and make fail to delete it.

Then what exactly do you expect Make to do about that?  We cannot
prevent child processes from opening files in a way that disallows
deletion by Make.

I understand it's not easy, but make is supposed to wait for all the child process chain to complete before proceeding.
 
We could probably wait in a loop until the deletion
succeeds, but I'm not sure this will work.  Can you try adding such a
loop to Make?  My system reproduces this with too low probability, so
I'm not a good candidate for this experiment.

Good idea. This patch works for me. I abused the existing `e` variable in order to avoid an additional #ifdef for declaring a variable for the loop. Feel free to change that:

diff --git a/commands.c b/commands.c
index 124b93e..da99710 100644
--- a/commands.c
+++ b/commands.c
@@ -640,12 +640,24 @@ delete_target (struct file *file, const char *on_behalf_of)
       && S_ISREG (st.st_mode)
       && FILE_TIMESTAMP_STAT_MODTIME (file->name, st) != file->last_mtime)
     {
+      int status;
       if (on_behalf_of)
         OSS (error, NILF,
              _("*** [%s] Deleting file '%s'"), on_behalf_of, file->name);
       else
         OS (error, NILF, _("*** Deleting file '%s'"), file->name);
-      if (unlink (file->name) < 0
+#ifdef WINDOWS32
+      for (e = 0; e < 10; ++e)
+        {
+#endif
+          status = unlink (file->name);
+#ifdef WINDOWS32
+          if (status == 0 || errno == ENOENT)
+            break;
+          Sleep(50);
+        }
+#endif
+      if (status < 0
           && errno != ENOENT)   /* It disappeared; so what.  */
         perror_with_name ("unlink: ", file->name);
     }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]