Skip to content

Commit 529c594

Browse files
committed
Don't error if the oppportunistic statat fails in fd_count
It was reported that old kernels (2.6) will return a failure if SYMLINK_NOFOLLOW is used, so lets check for errors here.
1 parent bd3f514 commit 529c594

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/process/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,12 +1181,13 @@ impl Process {
11811181
/// Calling this function is more efficient than calling `fd().unwrap().count()`
11821182
pub fn fd_count(&self) -> ProcResult<usize> {
11831183
// Use fast path if available (Linux v6.2): https://github.com/torvalds/linux/commit/f1f1f2569901
1184-
let stat = wrap_io_error!(
1184+
if let Ok(stat) = wrap_io_error!(
11851185
self.root.join("fd"),
11861186
rustix::fs::statat(&self.fd, "fd", AtFlags::SYMLINK_NOFOLLOW)
1187-
)?;
1188-
if stat.st_size > 0 {
1189-
return Ok(stat.st_size as usize);
1187+
) {
1188+
if stat.st_size > 0 {
1189+
return Ok(stat.st_size as usize);
1190+
}
11901191
}
11911192

11921193
let fds = wrap_io_error!(

0 commit comments

Comments
 (0)