Commit fb366f3cd4
Changed files (2)
lib
std
lib/std/c/darwin.zig
@@ -80,11 +80,11 @@ pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: u
pub const posix_spawnattr_t = *opaque {};
pub const posix_spawn_file_actions_t = *opaque {};
pub extern "c" fn posix_spawnattr_init(attr: *posix_spawnattr_t) c_int;
-pub extern "c" fn posix_spawnattr_destroy(attr: *posix_spawnattr_t) void;
+pub extern "c" fn posix_spawnattr_destroy(attr: *posix_spawnattr_t) c_int;
pub extern "c" fn posix_spawnattr_setflags(attr: *posix_spawnattr_t, flags: c_short) c_int;
pub extern "c" fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *c_short) c_int;
pub extern "c" fn posix_spawn_file_actions_init(actions: *posix_spawn_file_actions_t) c_int;
-pub extern "c" fn posix_spawn_file_actions_destroy(actions: *posix_spawn_file_actions_t) void;
+pub extern "c" fn posix_spawn_file_actions_destroy(actions: *posix_spawn_file_actions_t) c_int;
pub extern "c" fn posix_spawn_file_actions_addclose(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int;
pub extern "c" fn posix_spawn_file_actions_addopen(
actions: *posix_spawn_file_actions_t,
lib/std/os/posix_spawn.zig
@@ -47,8 +47,12 @@ const posix_spawn = if (builtin.target.isDarwin()) struct {
}
pub fn deinit(self: *Attr) void {
- system.posix_spawnattr_destroy(&self.attr);
- self.* = undefined;
+ defer self.* = undefined;
+ switch (errno(system.posix_spawnattr_destroy(&self.attr))) {
+ .SUCCESS => return,
+ .INVAL => unreachable, // Invalid parameters.
+ else => unreachable,
+ }
}
pub fn get(self: Attr) Error!u16 {
@@ -83,8 +87,12 @@ const posix_spawn = if (builtin.target.isDarwin()) struct {
}
pub fn deinit(self: *Actions) void {
- system.posix_spawn_file_actions_destroy(&self.actions);
- self.* = undefined;
+ defer self.* = undefined;
+ switch (errno(system.posix_spawn_file_actions_destroy(&self.actions))) {
+ .SUCCESS => return,
+ .INVAL => unreachable, // Invalid parameters.
+ else => unreachable,
+ }
}
pub fn open(self: *Actions, fd: fd_t, path: []const u8, flags: u32, mode: mode_t) Error!void {