aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-07-02 14:26:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-07-02 14:26:00 +0200
commitde97813722312ee64f0cb666eeb931d179a09ecc (patch)
tree4bf26aa737836a390ffb65957e15d1f26bdef844
parentb4968c4104c7f36fd6620af9e8b1262d8f694c9f (diff)
Hopefully fix flaky permission denied in `in` module on Windows
-rw-r--r--libbuild2/in/rule.cxx10
1 files changed, 9 insertions, 1 deletions
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.