On Fri, Jun 16, 2017 at 7:36 PM, Eli Zaretskii <e...@gnu.org> wrote: > > From: Orgad Shaneh <org...@gmail.com> > > Date: Fri, 16 Jun 2017 17:05:58 +0300 > > Cc: "bug-make@gnu.org" <bug-make@gnu.org>, Alexey Pavlov < > alex...@gmail.com> > > > > 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); }
_______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make