Skip to content

Commit

Permalink
Merge pull request #177 from noexcept/master
Browse files Browse the repository at this point in the history
fix infinite loop when errno is EINTR
  • Loading branch information
gulrak authored Jan 1, 2024
2 parents f19cbbb + fc19b58 commit 2fc4b46
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3974,7 +3974,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
}
ssize_t br, bw;
while (true) {
do { br = ::read(in, buffer.data(), buffer.size()); } while(errno == EINTR);
do { br = ::read(in, buffer.data(), buffer.size()); } while(errno == EINTR && !br);
if(!br) {
break;
}
Expand Down Expand Up @@ -5693,7 +5693,7 @@ class directory_iterator::impl
, _entry(nullptr)
{
if (!path.empty()) {
do { _dir = ::opendir(path.native().c_str()); } while(errno == EINTR);
do { _dir = ::opendir(path.native().c_str()); } while(errno == EINTR && !_dir);
if (!_dir) {
auto error = errno;
_base = filesystem::path();
Expand All @@ -5720,7 +5720,7 @@ class directory_iterator::impl
do {
skip = false;
errno = 0;
do { _entry = ::readdir(_dir); } while(errno == EINTR);
do { _entry = ::readdir(_dir); } while(errno == EINTR && !_entry);
if (_entry) {
_dir_entry._path = _base;
_dir_entry._path.append_name(_entry->d_name);
Expand Down

0 comments on commit 2fc4b46

Please sign in to comment.