[llvm] [FileSystem] Allow exclusive file lock (PR #114098)

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 19:25:49 PDT 2025


================
@@ -583,10 +583,14 @@ TEST_F(ProgramEnvTest, TestLockFileExclusive) {
     int FD2;
     ASSERT_NO_ERROR(fs::openFileForReadWrite(LockedFile, FD2,
                                              fs::CD_OpenExisting, fs::OF_None));
+    // File should be non-exclusive locked. Try acquire exclusive lock will fail
+    // but non-exclusive will succeed.
+    EXPECT_TRUE(
+        fs::tryLockFile(FD2, std::chrono::seconds(0), /*Exclusive=*/true));
+
+    EXPECT_FALSE(
+        fs::tryLockFile(FD2, std::chrono::seconds(0), /*Exclusive=*/false));
----------------
cachemeifyoucan wrote:

I think the comment is correct. Exclusive fail first and non-exclusive succeed second. I think the confusion is the first sentence, which should actually states `file is currently non-exclusively locked by other processes`.

https://github.com/llvm/llvm-project/pull/114098


More information about the llvm-commits mailing list