| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); |
| 3 | |
| 4 | const os = @import("../os.zig"); |
| 5 | const system = os.system; |
| 6 | const errno = system.getErrno; |
| 7 | const pid_t = system.pid_t; |
| 8 | const unexpectedErrno = os.unexpectedErrno; |
| 9 | const UnexpectedError = os.UnexpectedError; |
| 10 | |
| 11 | pub usingnamespace ptrace; |
| 12 | |
| 13 | const ptrace = if (builtin.target.isDarwin()) struct { |
| 14 | pub const PtraceError = error{ |
| 15 | ProcessNotFound, |
| 16 | PermissionDenied, |
| 17 | } || UnexpectedError; |
| 18 | |
| 19 | pub fn ptrace(request: i32, pid: pid_t) PtraceError!void { |
| 20 | switch (errno(system.ptrace(request, pid, null, 0))) { |
| 21 | .SUCCESS => return, |
| 22 | .SRCH => return error.ProcessNotFound, |
| 23 | .INVAL => unreachable, |
| 24 | .BUSY, .PERM => return error.PermissionDenied, |
| 25 | else => |err| return unexpectedErrno(err), |
| 26 | } |
| 27 | } |
| 28 | } else struct {}; |