about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-25 08:03:36 +0100
committerGitHub <noreply@github.com>2025-01-25 08:03:36 +0100
commit6cb2820b7e260659b959fa4be4626cdffcfb4a50 (patch)
treecfcc51d16afbba994afc29c356fbe722ab6ef355
parent7a79024ef477942102bf1a7df9d4c69b4b0d6a2b (diff)
parent571f3ed0c49353a6ceec040bb406a4b364b3766f (diff)
downloadrust-6cb2820b7e260659b959fa4be4626cdffcfb4a50.tar.gz
rust-6cb2820b7e260659b959fa4be4626cdffcfb4a50.zip
Rollup merge of #136009 - clubby789:pidfile-race, r=jieyouxu
bootstrap: Handle bootstrap lockfile race condition better

Fixes #135972

Tested by:
- Starting one build
- In another terminal, `echo -n '' > build/lock`
- Attempt to invoke bootstrap a second time
-rw-r--r--src/bootstrap/src/bin/main.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs
index b6552774195..8ebd6b8aa54 100644
--- a/src/bootstrap/src/bin/main.rs
+++ b/src/bootstrap/src/bin/main.rs
@@ -57,7 +57,9 @@ fn main() {
             }
             err => {
                 drop(err);
-                if let Ok(pid) = pid {
+                // #135972: We can reach this point when the lock has been taken,
+                // but the locker has not yet written its PID to the file
+                if let Some(pid) = pid.ok().filter(|pid| !pid.is_empty()) {
                     println!("WARNING: build directory locked by process {pid}, waiting for lock");
                 } else {
                     println!("WARNING: build directory locked, waiting for lock");