| ... | @@ -96,6 +96,22 @@ pub const Term = union(enum) { | ... | @@ -96,6 +96,22 @@ pub const Term = union(enum) { |
| 96 | signal: std.posix.SIG, | 96 | signal: std.posix.SIG, |
| 97 | stopped: std.posix.SIG, | 97 | stopped: std.posix.SIG, |
| 98 | unknown: u32, | 98 | unknown: u32, |
| | 99 | |
| | 100 | pub fn success(t: Term) bool { |
| | 101 | return switch (t) { |
| | 102 | .exited => |code| code == 0, |
| | 103 | else => false, |
| | 104 | }; |
| | 105 | } |
| | 106 | |
| | 107 | pub fn format(t: Term, w: *Io.Writer) Io.Writer.Error!void { |
| | 108 | switch (t) { |
| | 109 | .exited => |code| return w.print("exited with code {d}", .{code}), |
| | 110 | .signal => |sig| return w.print("terminated with signal {t}", .{sig}), |
| | 111 | .stopped => |sig| return w.print("stopped with signal {t}", .{sig}), |
| | 112 | .unknown => return w.writeAll("terminated unexpectedly"), |
| | 113 | } |
| | 114 | } |
| 99 | }; | 115 | }; |
| 100 | | 116 | |
| 101 | pub const Cwd = union(enum) { | 117 | pub const Cwd = union(enum) { |
| ... | @@ -135,3 +151,7 @@ pub fn wait(child: *Child, io: Io) WaitError!Term { | ... | @@ -135,3 +151,7 @@ pub fn wait(child: *Child, io: Io) WaitError!Term { |
| 135 | assert(child.id != null); | 151 | assert(child.id != null); |
| 136 | return io.vtable.childWait(io.userdata, child); | 152 | return io.vtable.childWait(io.userdata, child); |
| 137 | } | 153 | } |
| | 154 | |
| | 155 | test { |
| | 156 | _ = Term; |
| | 157 | } |