aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/posix_spawn.zig
diff options
context:
space:
mode:
authorAli Chraghi <alichraghi@pm.me>2022-09-28 20:21:33 +0330
committerVeikka Tuominen <git@vexu.eu>2022-10-13 13:21:19 +0200
commitfb366f3cd4a8a28a2a66753acc53d06a0d88c838 (patch)
tree4243467d2c6b4caeb4b87635014b77349bbcc072 /lib/std/os/posix_spawn.zig
parent6af0eeb58d1d220d407ce4c463eaeb25b35f2761 (diff)
downloadzig-fb366f3cd4a8a28a2a66753acc53d06a0d88c838.tar.gz
zig-fb366f3cd4a8a28a2a66753acc53d06a0d88c838.zip
std.c: fix incorrect return types
Closes #12964
Diffstat (limited to 'lib/std/os/posix_spawn.zig')
-rw-r--r--lib/std/os/posix_spawn.zig16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/std/os/posix_spawn.zig b/lib/std/os/posix_spawn.zig
index d36475df7f..32904a9423 100644
--- a/lib/std/os/posix_spawn.zig
+++ b/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 {