From de97813722312ee64f0cb666eeb931d179a09ecc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Jul 2020 14:26:00 +0200 Subject: Hopefully fix flaky permission denied in `in` module on Windows --- libbuild2/in/rule.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libbuild2/in/rule.cxx b/libbuild2/in/rule.cxx index f2c6ce4..16747ab 100644 --- a/libbuild2/in/rule.cxx +++ b/libbuild2/in/rule.cxx @@ -271,6 +271,14 @@ namespace build2 what = "open"; whom = &ip; ifdstream ifs (ip, ifdstream::badbit); + what = "open"; whom = &tp; +#ifdef _WIN32 + // We don't need to worry about permissions on Windows and trying to + // remove the file immediately before creating it sometimes can cause + // open to fail with permission denied. + // + ofdstream ofs (tp); +#else // See fdopen() for details (umask, etc). // permissions prm (permissions::ru | permissions::wu | @@ -286,10 +294,10 @@ namespace build2 // try_rmfile (tp, true /* ignore_error */); - what = "open"; whom = &tp; ofdstream ofs (fdopen (tp, fdopen_mode::out | fdopen_mode::create, prm)); +#endif auto_rmfile arm (tp); string s; // Reuse the buffer. -- cgit v1.1