On Tue 11 Jun 2024, Paul Slootman wrote: > This works for me. Patch attached.
I see I missed the case lseek() fails with another errno. Updated patch attached. Paul
--- library/meminfo.c.orig 2023-07-11 11:09:18.436786212 +0200 +++ library/meminfo.c 2024-06-11 13:11:12.878627527 +0200 @@ -646,12 +646,20 @@ // clear out the soon to be 'current' values memset(&info->hist.new, 0, sizeof(struct meminfo_data)); - if (-1 == info->meminfo_fd - && (-1 == (info->meminfo_fd = open(MEMINFO_FILE, O_RDONLY)))) - return 1; - - if (lseek(info->meminfo_fd, 0L, SEEK_SET) == -1) - return 1; + if (-1 == info->meminfo_fd) { + if (-1 == (info->meminfo_fd = open(MEMINFO_FILE, O_RDONLY))) + return 1; + } + else { + if (lseek(info->meminfo_fd, 0L, SEEK_SET) == -1) + if (ESPIPE == errno) { + close(info->meminfo_fd); + if (-1 == (info->meminfo_fd = open(MEMINFO_FILE, O_RDONLY))) + return 1; + } + else + return 1; + } for (;;) { if ((size = read(info->meminfo_fd, buf, sizeof(buf)-1)) < 0) {