Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Feb 2026 08:58:05 +0000
From:      Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 77385e9fac1c - stable/15 - cp: Expect EINTR while copying
Message-ID:  <69918a9d.1c15b.1b50ef97@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=77385e9fac1c34d7d3c1a778546ceb46c1b45796

commit 77385e9fac1c34d7d3c1a778546ceb46c1b45796
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-02-11 16:24:46 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-02-15 08:57:46 +0000

    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 7aa30669d6e04444b8ad1e4863a6e674fcac4afc)
---
 bin/cp/utils.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index 2036056ada68..2579ea0a9603 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -216,7 +216,10 @@ copy_file(const FTSENT *entp, bool dne, bool beneath)
 		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,
@@ -224,7 +227,7 @@ copy_file(const FTSENT *entp, bool dne, bool beneath)
 			    entp->fts_path, to.base, to.path,
 			    cp_pct(wtotal, fs->st_size));
 		}
-	} while (wcount > 0);
+	} while (wcount != 0);
 	if (wcount < 0) {
 		warn("%s", entp->fts_path);
 		rval = 1;


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69918a9d.1c15b.1b50ef97>