Skip to content

Commit

Permalink
Rollup merge of rust-lang#132737 - clubby789:lock-no-pid, r=jieyouxu
Browse files Browse the repository at this point in the history
bootstrap: Print better message if lock pid isn't available

Not actually sure why, but sometimes the PID isn't available so we print
```
WARNING: build directory locked by process , waiting for lock
```
This makes the message a bit nicer in this case
  • Loading branch information
workingjubilee authored Nov 8, 2024
2 parents 4130f44 + 1ee5ab3 commit 3ee523c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bootstrap/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() {
// Display PID of process holding the lock
// PID will be stored in a lock file
let lock_path = config.out.join("lock");
let pid = fs::read_to_string(&lock_path).unwrap_or_default();
let pid = fs::read_to_string(&lock_path);

build_lock = fd_lock::RwLock::new(t!(fs::OpenOptions::new()
.write(true)
Expand All @@ -47,7 +47,11 @@ fn main() {
}
err => {
drop(err);
println!("WARNING: build directory locked by process {pid}, waiting for lock");
if let Ok(pid) = pid {
println!("WARNING: build directory locked by process {pid}, waiting for lock");
} else {
println!("WARNING: build directory locked, waiting for lock");
}
let mut lock = t!(build_lock.write());
t!(lock.write(process::id().to_string().as_ref()));
lock
Expand Down

0 comments on commit 3ee523c

Please sign in to comment.