Skip to content

Commit cccdfd2

Browse files
committed
fsync(): be prepared to see EINTR
Some platforms, like NonStop do not automatically restart fsync() when interrupted by a signal, even when that signal is setup with SA_RESTART. This can lead to test breakage, e.g., where "--progress" is used, thus SIGALRM is sent often, and can interrupt an fsync() syscall. Make sure we deal with such a case by retrying the syscall ourselves. Luckily, we call fsync() fron a single wrapper, fsync_or_die(), so the fix is fairly isolated. Reported-by: Randall S. Becker <[email protected]> Helped-by: Jeff King <[email protected]> Helped-by: Taylor Blau <[email protected]> [jc: the above two did most of the work---I just tied the loose end] Helped-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 48bf2fa commit cccdfd2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

write-or-die.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ void fprintf_or_die(FILE *f, const char *fmt, ...)
5757

5858
void fsync_or_die(int fd, const char *msg)
5959
{
60-
if (fsync(fd) < 0) {
61-
die_errno("fsync error on '%s'", msg);
60+
while (fsync(fd) < 0) {
61+
if (errno != EINTR)
62+
die_errno("fsync error on '%s'", msg);
6263
}
6364
}
6465

0 commit comments

Comments
 (0)