@@ -3965,14 +3965,24 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
3965
3965
return false ;
3966
3966
}
3967
3967
ssize_t br, bw;
3968
- while ((br = ::read (in, buffer.data (), buffer.size ())) > 0 ) {
3968
+ while (true ) {
3969
+ do { br = ::read (in, buffer.data (), buffer.size ()); } while (errno == EINTR);
3970
+ if (!br) {
3971
+ break ;
3972
+ }
3973
+ if (br < 0 ) {
3974
+ ec = detail::make_system_error ();
3975
+ ::close (in);
3976
+ ::close (out);
3977
+ return false ;
3978
+ }
3969
3979
ssize_t offset = 0 ;
3970
3980
do {
3971
3981
if ((bw = ::write (out, buffer.data () + offset, static_cast <size_t >(br))) > 0 ) {
3972
3982
br -= bw;
3973
3983
offset += bw;
3974
3984
}
3975
- else if (bw < 0 ) {
3985
+ else if (bw < 0 && errno != EINTR ) {
3976
3986
ec = detail::make_system_error ();
3977
3987
::close (in);
3978
3988
::close (out);
@@ -5673,7 +5683,7 @@ class directory_iterator::impl
5673
5683
, _entry(nullptr )
5674
5684
{
5675
5685
if (!path.empty ()) {
5676
- _dir = ::opendir (path.native ().c_str ());
5686
+ do { _dir = ::opendir (path.native ().c_str ()); } while (errno == EINTR );
5677
5687
if (!_dir) {
5678
5688
auto error = errno;
5679
5689
_base = filesystem::path ();
@@ -5700,7 +5710,7 @@ class directory_iterator::impl
5700
5710
do {
5701
5711
skip = false ;
5702
5712
errno = 0 ;
5703
- _entry = ::readdir (_dir);
5713
+ do { _entry = ::readdir (_dir); } while (errno == EINTR );
5704
5714
if (_entry) {
5705
5715
_dir_entry._path = _base;
5706
5716
_dir_entry._path .append_name (_entry->d_name );
@@ -5714,7 +5724,7 @@ class directory_iterator::impl
5714
5724
::closedir (_dir);
5715
5725
_dir = nullptr ;
5716
5726
_dir_entry._path .clear ();
5717
- if (errno) {
5727
+ if (errno && errno != EINTR ) {
5718
5728
ec = detail::make_system_error ();
5719
5729
}
5720
5730
break ;
0 commit comments