Commit 28e12a7e36cd
tarball1 file changed+8-2
@@ -59,8 +59,7 @@ fn claim() -> Option<(u32, Vec<UnixListener>)> {
5959
let owner = std::fs::read_to_string(&lock)6060
.ok()6161
.and_then(|s| s.trim().parse::<u32>().ok());62
- let stale = owner63
- .is_some_and(|pid| !std::path::Path::new(&format!("/proc/{pid}")).exists());62
+ let stale = owner.is_some_and(|pid| !holds_display(pid));6463
if !stale || std::fs::remove_file(&lock).is_err() {6564
continue;6665
}@@ -405,3 +404,10 @@ pub fn logged<E: std::fmt::Display>(what: &str, result: Result<(), E>) {
405404
tracing::debug!("X11 {what} failed: {e}");406405
}407406
}407
+408
+/// Whether `pid` is alive and could own an X display lock. A SIGKILLed409
+/// monolith leaves its lock behind, and its pid may since belong to anything.410
+fn holds_display(pid: u32) -> bool {411
+ std::fs::read_to_string(format!("/proc/{pid}/comm"))412
+ .is_ok_and(|comm| comm.starts_with('X') || comm.trim() == "monolith")413
+}