From ff645d3aa25301cdcd1f9d165120186acc22dba4 Mon Sep 17 00:00:00 2001 From: Nandan Acharya Date: Sun, 22 Feb 2026 22:48:16 +0530 Subject: [PATCH] unix: handle EINTR in uv_resident_set_memory on AIX and SunOS --- src/unix/aix.c | 10 ++++++++-- src/unix/sunos.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/unix/aix.c b/src/unix/aix.c index 4c0f4adb4..a1e091376 100644 --- a/src/unix/aix.c +++ b/src/unix/aix.c @@ -997,6 +997,7 @@ void uv__process_title_cleanup(void) { int uv_resident_set_memory(size_t* rss) { char pp[64]; psinfo_t psinfo; + ssize_t nread; int err; int fd; @@ -1006,11 +1007,16 @@ int uv_resident_set_memory(size_t* rss) { if (fd == -1) return UV__ERR(errno); - /* FIXME(bnoordhuis) Handle EINTR. */ + do + nread = read(fd, &psinfo, sizeof(psinfo)); + while (nread == -1 && errno == EINTR); + err = UV_EINVAL; - if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) { + if (nread == (ssize_t) sizeof(psinfo)) { *rss = (size_t)psinfo.pr_rssize * 1024; err = 0; + } else if (nread < 0) { + err = UV__ERR(errno); } uv__close(fd); diff --git a/src/unix/sunos.c b/src/unix/sunos.c index c241e3506..e8d01daa2 100644 --- a/src/unix/sunos.c +++ b/src/unix/sunos.c @@ -612,6 +612,7 @@ void uv__fs_event_close(uv_fs_event_t* handle) { int uv_resident_set_memory(size_t* rss) { psinfo_t psinfo; + ssize_t nread; int err; int fd; @@ -619,11 +620,16 @@ int uv_resident_set_memory(size_t* rss) { if (fd == -1) return UV__ERR(errno); - /* FIXME(bnoordhuis) Handle EINTR. */ + do + nread = read(fd, &psinfo, sizeof(psinfo)); + while (nread == -1 && errno == EINTR); + err = UV_EINVAL; - if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) { + if (nread == (ssize_t) sizeof(psinfo)) { *rss = (size_t)psinfo.pr_rssize * 1024; err = 0; + } else if (nread < 0) { + err = UV__ERR(errno); } uv__close(fd);