authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-10 21:04:20+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-10 21:04:20+01:00
log9acfd167fa80e14b7beb1eb29830cb0c7d50e586
treebf95345561b37a4643287029ab80588045a1da17
parentec25b138481e16f2d73d12ed6ffacd8e7ba65e94
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.process: add PermissionDenied to ProtectMemoryError (for OpenBSD)

See EPERM notes on https://man.openbsd.org/mprotect.2.

1 files changed, 5 insertions(+), 0 deletions(-)

lib/std/process.zig+5
......@@ -1004,6 +1004,10 @@ pub fn unlockMemoryAll() UnlockMemoryError!void {
10041004
10051005pub const ProtectMemoryError = error{
10061006 UnsupportedOperation,
1007 /// OpenBSD will refuse to change memory protection if the specified region
1008 /// contains any pages that have previously been marked immutable using the
1009 /// `mimmutable` function.
1010 PermissionDenied,
10071011 /// The memory cannot be given the specified access. This can happen, for
10081012 /// example, if you memory map a file to which you have read-only access,
10091013 /// then use `protectMemory` to mark it writable.
......@@ -1052,6 +1056,7 @@ pub fn protectMemory(
10521056 };
10531057 switch (posix.errno(posix.system.mprotect(memory.ptr, memory.len, flags))) {
10541058 .SUCCESS => return,
1059 .PERM => return error.PermissionDenied,
10551060 .INVAL => |err| return std.Io.Threaded.errnoBug(err),
10561061 .ACCES => return error.AccessDenied,
10571062 .NOMEM => return error.OutOfMemory,