mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 07:03:11 +00:00
std: don't leak a process in Child.run in case of an error
Closes: #22433
This commit is contained in:
parent
c104e86442
commit
4de2b1ea65
@ -428,12 +428,15 @@ pub fn run(args: struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try child.spawn();
|
try child.spawn();
|
||||||
|
errdefer {
|
||||||
|
_ = child.kill() catch {};
|
||||||
|
}
|
||||||
try child.collectOutput(&stdout, &stderr, args.max_output_bytes);
|
try child.collectOutput(&stdout, &stderr, args.max_output_bytes);
|
||||||
|
|
||||||
return RunResult{
|
return RunResult{
|
||||||
.term = try child.wait(),
|
|
||||||
.stdout = try stdout.toOwnedSlice(),
|
.stdout = try stdout.toOwnedSlice(),
|
||||||
.stderr = try stderr.toOwnedSlice(),
|
.stderr = try stderr.toOwnedSlice(),
|
||||||
|
.term = try child.wait(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user