Restore errno save/restore in pages_purge_process_madvise_impl

TODO comment focused on free only, but this path is reachable via
other calls and it is safer to leave errno preservation here.
This commit is contained in:
Slobodan Predolac 2026-04-30 15:42:19 -07:00
parent 9ae0c1b6d3
commit 86f058287f

View file

@ -662,6 +662,7 @@ pages_purge_process_madvise_impl(
return true;
}
int saved_errno = get_errno();
size_t purged_bytes = (size_t)syscall(JE_SYS_PROCESS_MADVISE_NR,
PIDFD_SELF, (struct iovec *)vec, vec_len, MADV_DONTNEED, 0);
if (purged_bytes == (size_t)-1) {
@ -671,6 +672,7 @@ pages_purge_process_madvise_impl(
atomic_store_b(
&process_madvise_gate, false, ATOMIC_RELAXED);
}
set_errno(saved_errno);
}
return purged_bytes != total_bytes;