authorgravatar for github@garrettsquire.comGarrett Squire <github@garrettsquire.com> 2021-03-24 18:27:56-07:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-06-12 23:13:14+03:00
loga6d72fea06364da26b4efacb188303c5bddf5da3
tree07dbec9fc4e1923a4c23f720913f6b3a2ff4d4c9
parentea4a25287eb65e639fd75d425f320663e6e8dca1

Make std.ChildProcess exit code u8 to match std.process.exit

This patch adjusts the exit code for a child process to be a u8. Since the WEXITSTATUS macro returns the lower eight bits, it's safe to assume that we can truncate the returned u32.

8 files changed, 16 insertions(+), 16 deletions(-)

lib/std/child_process.zig+2-2
......@@ -78,7 +78,7 @@ pub const ChildProcess = struct {
7878 } || os.ExecveError || os.SetIdError || os.ChangeCurDirError || windows.CreateProcessError || windows.WaitForSingleObjectError;
7979
8080 pub const Term = union(enum) {
81 Exited: u32,
81 Exited: u8,
8282 Signal: u32,
8383 Stopped: u32,
8484 Unknown: u32,
......@@ -347,7 +347,7 @@ pub const ChildProcess = struct {
347347 if (windows.kernel32.GetExitCodeProcess(self.handle, &exit_code) == 0) {
348348 break :x Term{ .Unknown = 0 };
349349 } else {
350 break :x Term{ .Exited = exit_code };
350 break :x Term{ .Exited = @truncate(u8, exit_code) };
351351 }
352352 });
353353
lib/std/os/bits/darwin.zig+2-2
......@@ -844,8 +844,8 @@ fn wstatus(x: u32) u32 {
844844 return x & 0o177;
845845}
846846const wstopped = 0o177;
847pub fn WEXITSTATUS(x: u32) u32 {
848 return x >> 8;
847pub fn WEXITSTATUS(x: u32) u8 {
848 return @intCast(u8, x >> 8);
849849}
850850pub fn WTERMSIG(x: u32) u32 {
851851 return wstatus(x);
lib/std/os/bits/dragonfly.zig+2-2
......@@ -332,8 +332,8 @@ pub const AT_REMOVEDIR = 2;
332332pub const AT_EACCESS = 4;
333333pub const AT_SYMLINK_FOLLOW = 8;
334334
335pub fn WEXITSTATUS(s: u32) u32 {
336 return (s & 0xff00) >> 8;
335pub fn WEXITSTATUS(s: u32) u8 {
336 return @intCast(u8, (s & 0xff00) >> 8);
337337}
338338pub fn WTERMSIG(s: u32) u32 {
339339 return s & 0x7f;
lib/std/os/bits/freebsd.zig+2-2
......@@ -729,8 +729,8 @@ pub const TIOCGSID = 0x40047463;
729729pub const TIOCGPTN = 0x4004740f;
730730pub const TIOCSIG = 0x2004745f;
731731
732pub fn WEXITSTATUS(s: u32) u32 {
733 return (s & 0xff00) >> 8;
732pub fn WEXITSTATUS(s: u32) u8 {
733 return @intCast(u8, (s & 0xff00) >> 8);
734734}
735735pub fn WTERMSIG(s: u32) u32 {
736736 return s & 0x7f;
lib/std/os/bits/haiku.zig+2-2
......@@ -661,8 +661,8 @@ pub const TIOCSBRK = 0x8020;
661661pub const TIOCCBRK = 0x8021;
662662pub const TIOCGSID = 0x8024;
663663
664pub fn WEXITSTATUS(s: u32) u32 {
665 return (s & 0xff);
664pub fn WEXITSTATUS(s: u32) u8 {
665 return @intCast(u8, s & 0xff);
666666}
667667
668668pub fn WTERMSIG(s: u32) u32 {
lib/std/os/bits/linux.zig+2-2
......@@ -1043,8 +1043,8 @@ pub const TFD_CLOEXEC = O_CLOEXEC;
10431043pub const TFD_TIMER_ABSTIME = 1;
10441044pub const TFD_TIMER_CANCEL_ON_SET = (1 << 1);
10451045
1046pub fn WEXITSTATUS(s: u32) u32 {
1047 return (s & 0xff00) >> 8;
1046pub fn WEXITSTATUS(s: u32) u8 {
1047 return @intCast(u8, (s & 0xff00) >> 8);
10481048}
10491049pub fn WTERMSIG(s: u32) u32 {
10501050 return s & 0x7f;
lib/std/os/bits/netbsd.zig+2-2
......@@ -686,8 +686,8 @@ pub const TIOCSWINSZ = 0x80087467;
686686pub const TIOCUCNTL = 0x80047466;
687687pub const TIOCXMTFRAME = 0x80087444;
688688
689pub fn WEXITSTATUS(s: u32) u32 {
690 return (s >> 8) & 0xff;
689pub fn WEXITSTATUS(s: u32) u8 {
690 return @intCast(u8, (s >> 8) & 0xff);
691691}
692692pub fn WTERMSIG(s: u32) u32 {
693693 return s & 0x7f;
lib/std/os/bits/openbsd.zig+2-2
......@@ -669,8 +669,8 @@ pub const TIOCSWINSZ = 0x80087467;
669669pub const TIOCUCNTL = 0x80047466;
670670pub const TIOCXMTFRAME = 0x80087444;
671671
672pub fn WEXITSTATUS(s: u32) u32 {
673 return (s >> 8) & 0xff;
672pub fn WEXITSTATUS(s: u32) u8 {
673 return @intCast(u8, (s >> 8) & 0xff);
674674}
675675pub fn WTERMSIG(s: u32) u32 {
676676 return (s & 0x7f);