+ // If the lock file is still expected to be there, check whether it still
+ // is.
+ if (!LockFileGone) {
+ bool Exists;
+ if (!sys::fs::exists(LockFileName.str(), Exists) && !Exists) {
+ LockFileGone = true;
+ LockFileJustDisappeared = true;
+ }
+ }
+
+ // If the lock file is no longer there, check if the original file is
+ // available now.
+ if (LockFileGone) {
+ if (sys::fs::exists(FileName.str())) {
+ return Res_Success;
+ }
+
+ // The lock file is gone, so now we're waiting for the original file to
+ // show up. If this just happened, reset our waiting intervals and keep
+ // waiting.
+ if (LockFileJustDisappeared) {
+ MaxSeconds = 5;
+
+#if LLVM_ON_WIN32
+ Interval = 1;
+#else
+ Interval.tv_sec = 0;
+ Interval.tv_nsec = 1000000;
+#endif
+ continue;
+ }
+ }
+
+ // If we're looking for the lock file to disappear, but the process
+ // owning the lock died without cleaning up, just bail out.
+ if (!LockFileGone &&
+ !processStillExecuting((*Owner).first, (*Owner).second)) {
+ return Res_OwnerDied;
+ }