fix: subprocess should exit if stdout/err cannot be read
This commit is contained in:
parent
a7b3c3e1e8
commit
45d5c282bd
1 changed files with 5 additions and 2 deletions
|
@ -210,12 +210,14 @@ const Proc = struct {
|
||||||
if (self.child.stdin) |*fd| {
|
if (self.child.stdin) |*fd| {
|
||||||
fd.close();
|
fd.close();
|
||||||
self.child.stdin = null;
|
self.child.stdin = null;
|
||||||
|
tp.env.get().trace(tp.message.fmt(.{ self.tag, "stdin", "closed" }).to(tp.message.c_buffer_type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch_stdout(self: *Proc) tp.result {
|
fn dispatch_stdout(self: *Proc) tp.result {
|
||||||
var buffer: [max_chunk_size]u8 = undefined;
|
var buffer: [max_chunk_size]u8 = undefined;
|
||||||
const bytes = self.child.stdout.?.read(&buffer) catch |e| switch (e) {
|
const stdout = self.child.stdout orelse return tp.exit("cannot read closed stdout");
|
||||||
|
const bytes = stdout.read(&buffer) catch |e| switch (e) {
|
||||||
error.WouldBlock => return,
|
error.WouldBlock => return,
|
||||||
else => return tp.exit_error(e),
|
else => return tp.exit_error(e),
|
||||||
};
|
};
|
||||||
|
@ -226,7 +228,8 @@ const Proc = struct {
|
||||||
|
|
||||||
fn dispatch_stderr(self: *Proc) tp.result {
|
fn dispatch_stderr(self: *Proc) tp.result {
|
||||||
var buffer: [max_chunk_size]u8 = undefined;
|
var buffer: [max_chunk_size]u8 = undefined;
|
||||||
const bytes = self.child.stderr.?.read(&buffer) catch |e| switch (e) {
|
const stderr = self.child.stderr orelse return tp.exit("cannot read closed stderr");
|
||||||
|
const bytes = stderr.read(&buffer) catch |e| switch (e) {
|
||||||
error.WouldBlock => return,
|
error.WouldBlock => return,
|
||||||
else => return tp.exit_error(e),
|
else => return tp.exit_error(e),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue