Skip to content

Commit

Permalink
DirReaderLinux: Don't crash if the directory is deleted
Browse files Browse the repository at this point in the history
If Next() is called but the directory has been deleted, debug builds
just crash. Instead, don't crash because this is normal behavior,
especially for reading /proc/<pid> directories that can disappear
any time a process dies.

Change-Id: If110ca05d576b205ba4113fa13d0f8e044beaf6a
Bug: 1493493
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4961577
Commit-Queue: Lei Zhang <thestig@chromium.org>
Commit-Queue: Matthew Denton <mpdenton@chromium.org>
Auto-Submit: Matthew Denton <mpdenton@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1213066}
  • Loading branch information
mdenton8 authored and Chromium LUCI CQ committed Oct 21, 2023
1 parent ad43a62 commit 45730fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/files/dir_reader_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ class DirReaderLinux {
if (r == 0)
return false;
if (r < 0) {
DPLOG(FATAL) << "getdents64 failed";
if (errno != ENOENT) {
DPLOG(FATAL) << "getdents64 failed";
}
return false;
}
size_ = static_cast<size_t>(r);
Expand Down

0 comments on commit 45730fa

Please sign in to comment.