Function ptrace [src]
Prototype
pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError!void Parameters
request: u32pid: pid_taddr: usizesignal: usize Possible Errors
The Operating System returned an undocumented error code.
This error is in theory not possible, but it would be better to handle this error than to invoke undefined behavior.
When this error code is observed, it usually means the Zig Standard Library needs a small patch to add the error code to the error set for the respective function.
Source
pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError!void {
if (native_os == .windows or native_os == .wasi)
@compileError("Unsupported OS");
return switch (native_os) {
.linux => switch (errno(linux.ptrace(request, pid, addr, signal, 0))) {
.SUCCESS => {},
.SRCH => error.ProcessNotFound,
.FAULT => unreachable,
.INVAL => unreachable,
.IO => return error.InputOutput,
.PERM => error.PermissionDenied,
.BUSY => error.DeviceBusy,
else => |err| return unexpectedErrno(err),
},
.macos, .ios, .tvos, .watchos, .visionos => switch (errno(std.c.ptrace(
@intCast(request),
pid,
@ptrFromInt(addr),
@intCast(signal),
))) {
.SUCCESS => {},
.SRCH => error.ProcessNotFound,
.INVAL => unreachable,
.PERM => error.PermissionDenied,
.BUSY => error.DeviceBusy,
else => |err| return unexpectedErrno(err),
},
else => switch (errno(system.ptrace(request, pid, addr, signal))) {
.SUCCESS => {},
.SRCH => error.ProcessNotFound,
.INVAL => unreachable,
.PERM => error.PermissionDenied,
.BUSY => error.DeviceBusy,
else => |err| return unexpectedErrno(err),
},
};
}