mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
cp: Expect EINTR while copying
Both copy_file_range() and copy_fallback() can be interrupted before
they have read anything at all, in which case they return -1 and set
errno to EINTR. If that happens, we should retry, not fail.
PR: 293028
MFC after: 1 week
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55167
(cherry picked from commit 7aa30669d6)
This commit is contained in:
1 parent
9349f96514
commit
f1a86b35de
1 file changed
+5
-2
+5
-2
@@ -213,7 +213,10 @@ copy_file(const FTSENT *entp, int dne)
|
||||
if (!use_copy_file_range) {
|
||||
wcount = copy_fallback(from_fd, to_fd);
|
||||
}
|
||||
wtotal += wcount;
|
||||
if (wcount >= 0)
|
||||
wtotal += wcount;
|
||||
else if (errno != EINTR)
|
||||
break;
|
||||
if (info) {
|
||||
info = 0;
|
||||
(void)fprintf(stderr,
|
||||
@@ -221,7 +224,7 @@ copy_file(const FTSENT *entp, int dne)
|
||||
entp->fts_path, to.p_path,
|
||||
cp_pct(wtotal, fs->st_size));
|
||||
}
|
||||
} while (wcount > 0);
|
||||
} while (wcount != 0);
|
||||
if (wcount < 0) {
|
||||
warn("%s", entp->fts_path);
|
||||
rval = 1;
|
||||
|
||||
Reference in new issue
Block a user