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 {...@@ -78,7 +78,7 @@ pub const ChildProcess = struct {
78 } || os.ExecveError || os.SetIdError || os.ChangeCurDirError || windows.CreateProcessError || windows.WaitForSingleObjectError;78 } || os.ExecveError || os.SetIdError || os.ChangeCurDirError || windows.CreateProcessError || windows.WaitForSingleObjectError;
7979
80 pub const Term = union(enum) {80 pub const Term = union(enum) {
81 Exited: u32,81 Exited: u8,
82 Signal: u32,82 Signal: u32,
83 Stopped: u32,83 Stopped: u32,
84 Unknown: u32,84 Unknown: u32,
...@@ -347,7 +347,7 @@ pub const ChildProcess = struct {...@@ -347,7 +347,7 @@ pub const ChildProcess = struct {
347 if (windows.kernel32.GetExitCodeProcess(self.handle, &exit_code) == 0) {347 if (windows.kernel32.GetExitCodeProcess(self.handle, &exit_code) == 0) {
348 break :x Term{ .Unknown = 0 };348 break :x Term{ .Unknown = 0 };
349 } else {349 } else {
350 break :x Term{ .Exited = exit_code };350 break :x Term{ .Exited = @truncate(u8, exit_code) };
351 }351 }
352 });352 });
353353
lib/std/os/bits/darwin.zig+2-2
...@@ -844,8 +844,8 @@ fn wstatus(x: u32) u32 {...@@ -844,8 +844,8 @@ fn wstatus(x: u32) u32 {
844 return x & 0o177;844 return x & 0o177;
845}845}
846const wstopped = 0o177;846const wstopped = 0o177;
847pub fn WEXITSTATUS(x: u32) u32 {847pub fn WEXITSTATUS(x: u32) u8 {
848 return x >> 8;848 return @intCast(u8, x >> 8);
849}849}
850pub fn WTERMSIG(x: u32) u32 {850pub fn WTERMSIG(x: u32) u32 {
851 return wstatus(x);851 return wstatus(x);
lib/std/os/bits/dragonfly.zig+2-2
...@@ -332,8 +332,8 @@ pub const AT_REMOVEDIR = 2;...@@ -332,8 +332,8 @@ pub const AT_REMOVEDIR = 2;
332pub const AT_EACCESS = 4;332pub const AT_EACCESS = 4;
333pub const AT_SYMLINK_FOLLOW = 8;333pub const AT_SYMLINK_FOLLOW = 8;
334334
335pub fn WEXITSTATUS(s: u32) u32 {335pub fn WEXITSTATUS(s: u32) u8 {
336 return (s & 0xff00) >> 8;336 return @intCast(u8, (s & 0xff00) >> 8);
337}337}
338pub fn WTERMSIG(s: u32) u32 {338pub fn WTERMSIG(s: u32) u32 {
339 return s & 0x7f;339 return s & 0x7f;
lib/std/os/bits/freebsd.zig+2-2
...@@ -729,8 +729,8 @@ pub const TIOCGSID = 0x40047463;...@@ -729,8 +729,8 @@ pub const TIOCGSID = 0x40047463;
729pub const TIOCGPTN = 0x4004740f;729pub const TIOCGPTN = 0x4004740f;
730pub const TIOCSIG = 0x2004745f;730pub const TIOCSIG = 0x2004745f;
731731
732pub fn WEXITSTATUS(s: u32) u32 {732pub fn WEXITSTATUS(s: u32) u8 {
733 return (s & 0xff00) >> 8;733 return @intCast(u8, (s & 0xff00) >> 8);
734}734}
735pub fn WTERMSIG(s: u32) u32 {735pub fn WTERMSIG(s: u32) u32 {
736 return s & 0x7f;736 return s & 0x7f;
lib/std/os/bits/haiku.zig+2-2
...@@ -661,8 +661,8 @@ pub const TIOCSBRK = 0x8020;...@@ -661,8 +661,8 @@ pub const TIOCSBRK = 0x8020;
661pub const TIOCCBRK = 0x8021;661pub const TIOCCBRK = 0x8021;
662pub const TIOCGSID = 0x8024;662pub const TIOCGSID = 0x8024;
663663
664pub fn WEXITSTATUS(s: u32) u32 {664pub fn WEXITSTATUS(s: u32) u8 {
665 return (s & 0xff);665 return @intCast(u8, s & 0xff);
666}666}
667667
668pub fn WTERMSIG(s: u32) u32 {668pub fn WTERMSIG(s: u32) u32 {
lib/std/os/bits/linux.zig+2-2
...@@ -1043,8 +1043,8 @@ pub const TFD_CLOEXEC = O_CLOEXEC;...@@ -1043,8 +1043,8 @@ pub const TFD_CLOEXEC = O_CLOEXEC;
1043pub const TFD_TIMER_ABSTIME = 1;1043pub const TFD_TIMER_ABSTIME = 1;
1044pub const TFD_TIMER_CANCEL_ON_SET = (1 << 1);1044pub const TFD_TIMER_CANCEL_ON_SET = (1 << 1);
10451045
1046pub fn WEXITSTATUS(s: u32) u32 {1046pub fn WEXITSTATUS(s: u32) u8 {
1047 return (s & 0xff00) >> 8;1047 return @intCast(u8, (s & 0xff00) >> 8);
1048}1048}
1049pub fn WTERMSIG(s: u32) u32 {1049pub fn WTERMSIG(s: u32) u32 {
1050 return s & 0x7f;1050 return s & 0x7f;
lib/std/os/bits/netbsd.zig+2-2
...@@ -686,8 +686,8 @@ pub const TIOCSWINSZ = 0x80087467;...@@ -686,8 +686,8 @@ pub const TIOCSWINSZ = 0x80087467;
686pub const TIOCUCNTL = 0x80047466;686pub const TIOCUCNTL = 0x80047466;
687pub const TIOCXMTFRAME = 0x80087444;687pub const TIOCXMTFRAME = 0x80087444;
688688
689pub fn WEXITSTATUS(s: u32) u32 {689pub fn WEXITSTATUS(s: u32) u8 {
690 return (s >> 8) & 0xff;690 return @intCast(u8, (s >> 8) & 0xff);
691}691}
692pub fn WTERMSIG(s: u32) u32 {692pub fn WTERMSIG(s: u32) u32 {
693 return s & 0x7f;693 return s & 0x7f;
lib/std/os/bits/openbsd.zig+2-2
...@@ -669,8 +669,8 @@ pub const TIOCSWINSZ = 0x80087467;...@@ -669,8 +669,8 @@ pub const TIOCSWINSZ = 0x80087467;
669pub const TIOCUCNTL = 0x80047466;669pub const TIOCUCNTL = 0x80047466;
670pub const TIOCXMTFRAME = 0x80087444;670pub const TIOCXMTFRAME = 0x80087444;
671671
672pub fn WEXITSTATUS(s: u32) u32 {672pub fn WEXITSTATUS(s: u32) u8 {
673 return (s >> 8) & 0xff;673 return @intCast(u8, (s >> 8) & 0xff);
674}674}
675pub fn WTERMSIG(s: u32) u32 {675pub fn WTERMSIG(s: u32) u32 {
676 return (s & 0x7f);676 return (s & 0x7f);