authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-17 15:16:31+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-18 21:54:05+01:00
log6f15eedff1bd32085808ab58f095ab549b493745
treea5163457ff5865162d18bdead72ec12d95d4eedc
parent0aab3bda126b0221f81533b335c7a6a01749344b

darwin: put posix spawn constants in POSIX_SPAWN struct


2 files changed, 19 insertions(+), 13 deletions(-)

lib/std/c/darwin.zig+12-10
......@@ -3033,16 +3033,18 @@ pub const caddr_t = ?[*]u8;
30333033
30343034pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: caddr_t, data: c_int) c_int;
30353035
3036pub const POSIX_SPAWN_RESETIDS = 0x0001;
3037pub const POSIX_SPAWN_SETPGROUP = 0x0002;
3038pub const POSIX_SPAWN_SETSIGDEF = 0x0004;
3039pub const POSIX_SPAWN_SETSIGMASK = 0x0008;
3040pub const POSIX_SPAWN_SETEXEC = 0x0040;
3041pub const POSIX_SPAWN_START_SUSPENDED = 0x0080;
3042pub const _POSIX_SPAWN_DISABLE_ASLR = 0x0100;
3043pub const POSIX_SPAWN_SETSID = 0x0400;
3044pub const _POSIX_SPAWN_RESLIDE = 0x0800;
3045pub const POSIX_SPAWN_CLOEXEC_DEFAULT = 0x4000;
3036pub const POSIX_SPAWN = struct {
3037 pub const RESETIDS = 0x0001;
3038 pub const SETPGROUP = 0x0002;
3039 pub const SETSIGDEF = 0x0004;
3040 pub const SETSIGMASK = 0x0008;
3041 pub const SETEXEC = 0x0040;
3042 pub const START_SUSPENDED = 0x0080;
3043 pub const DISABLE_ASLR = 0x0100;
3044 pub const SETSID = 0x0400;
3045 pub const RESLIDE = 0x0800;
3046 pub const CLOEXEC_DEFAULT = 0x4000;
3047};
30463048
30473049pub const posix_spawnattr_t = *opaque {};
30483050pub const posix_spawn_file_actions_t = *opaque {};
src/main.zig+7-3
......@@ -3852,11 +3852,15 @@ fn runOrTestHotSwap(
38523852 switch (builtin.target.os.tag) {
38533853 .macos, .ios, .tvos, .watchos => {
38543854 const PosixSpawn = std.os.darwin.PosixSpawn;
3855
38553856 var attr = try PosixSpawn.Attr.init();
38563857 defer attr.deinit();
3857 const flags: u16 = std.os.darwin.POSIX_SPAWN_SETSIGDEF |
3858 std.os.darwin.POSIX_SPAWN_SETSIGMASK |
3859 std.os.darwin._POSIX_SPAWN_DISABLE_ASLR;
3858
3859 // ASLR is probably a good default for better debugging experience/programming
3860 // with hot-code updates in mind. However, we can also make it work with ASLR on.
3861 const flags: u16 = std.os.darwin.POSIX_SPAWN.SETSIGDEF |
3862 std.os.darwin.POSIX_SPAWN.SETSIGMASK |
3863 std.os.darwin.POSIX_SPAWN.DISABLE_ASLR;
38603864 try attr.set(flags);
38613865
38623866 var arena_allocator = std.heap.ArenaAllocator.init(gpa);