From 8a231568f9f11ad75117237dc8cba01329d5a12f Mon Sep 17 00:00:00 2001 From: lexprfuncall <5360361+lexprfuncall@users.noreply.github.com> Date: Thu, 21 Aug 2025 20:44:18 -0700 Subject: [PATCH] Handle interruptions and retries of read(2) and write(2) --- include/jemalloc/internal/malloc_io.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/jemalloc/internal/malloc_io.h b/include/jemalloc/internal/malloc_io.h index 0f82f678..5e0805ed 100644 --- a/include/jemalloc/internal/malloc_io.h +++ b/include/jemalloc/internal/malloc_io.h @@ -96,6 +96,11 @@ malloc_write_fd(int fd, const void *buf, size_t count) { &((const byte_t *)buf)[bytes_written], count - bytes_written); if (result < 0) { +#ifndef _WIN32 + if (errno == EINTR) { + continue; + } +#endif return result; } bytes_written += result; @@ -124,6 +129,11 @@ malloc_read_fd(int fd, void *buf, size_t count) { ssize_t result = malloc_read_fd_syscall( fd, &((byte_t *)buf)[bytes_read], count - bytes_read); if (result < 0) { +#ifndef _WIN32 + if (errno == EINTR) { + continue; + } +#endif return result; } else if (result == 0) { break;