std: don't leak a process in Child.run in case of an error

Closes: #22433
This commit is contained in:
Alex Kladov 2025-01-30 12:01:53 +00:00 committed by Isaac Freund
parent c104e86442
commit 4de2b1ea65

View file

@ -428,12 +428,15 @@ pub fn run(args: struct {
}
try child.spawn();
errdefer {
_ = child.kill() catch {};
}
try child.collectOutput(&stdout, &stderr, args.max_output_bytes);
return RunResult{
.term = try child.wait(),
.stdout = try stdout.toOwnedSlice(),
.stderr = try stderr.toOwnedSlice(),
.term = try child.wait(),
};
}