incr-check: Kill child process on error

Since the child process is spawned with the tmp directory as its CWD, the child process opens it without DELETE access. On error, the child process would still be alive while the tmp directory is attempting to be deleted, so it would fail with `.SHARING_VIOLATION => return error.FileBusy`.

Fixes arguably the least important part of #22510, since it's only the directory itself that would fail to get deleted, all the files inside would get deleted just fine.
This commit is contained in:
Ryan Liptak 2025-11-08 23:45:31 -08:00 committed by GitHub
parent b31a03f134
commit 5358af7ba4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -197,6 +197,9 @@ pub fn main() !void {
}; };
try child.spawn(); try child.spawn();
errdefer {
_ = child.kill() catch {};
}
var poller = Io.poll(arena, Eval.StreamEnum, .{ var poller = Io.poll(arena, Eval.StreamEnum, .{
.stdout = child.stdout.?, .stdout = child.stdout.?,
@ -585,6 +588,8 @@ const Eval = struct {
fn fatal(eval: *Eval, comptime fmt: []const u8, args: anytype) noreturn { fn fatal(eval: *Eval, comptime fmt: []const u8, args: anytype) noreturn {
eval.tmp_dir.close(); eval.tmp_dir.close();
if (!eval.preserve_tmp_on_fatal) { if (!eval.preserve_tmp_on_fatal) {
// Kill the child since it holds an open handle to its CWD which is the tmp dir path
_ = eval.child.kill() catch {};
std.fs.cwd().deleteTree(eval.tmp_dir_path) catch |err| { std.fs.cwd().deleteTree(eval.tmp_dir_path) catch |err| {
std.log.warn("failed to delete tree '{s}': {s}", .{ eval.tmp_dir_path, @errorName(err) }); std.log.warn("failed to delete tree '{s}': {s}", .{ eval.tmp_dir_path, @errorName(err) });
}; };