diff --git a/src/pthread/mod.rs b/src/pthread/mod.rs index 0cd5d1d088..7755f7153f 100644 --- a/src/pthread/mod.rs +++ b/src/pthread/mod.rs @@ -481,17 +481,18 @@ pub fn mutex_owner_id_is_live(owner: u32) -> bool { // For Redox, attempt to open the thread's "name" handle via // the proc scheme. If the thread is alive, the open succeeds; // if it has exited and been reaped, the open returns ENOENT. - let path = format!("proc:{}/name", owner); + let path = alloc::format!("proc:{}/name\0", owner); let cstr = match crate::c_str::CStr::from_bytes_with_nul(path.as_bytes()) { Ok(c) => c, Err(_) => return false, }; - let fd = crate::platform::Sys::open(cstr.as_ptr(), crate::header::fcntl::O_RDONLY, 0); - if fd >= 0 { - let _ = crate::platform::Sys::close(fd); - true - } else { - false + let fd = crate::platform::Sys::open(cstr, crate::header::fcntl::O_RDONLY, 0); + match fd { + Ok(fd) => { + let _ = crate::platform::Sys::close(fd); + true + } + Err(_) => false, } } #[cfg(target_os = "linux")]