authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-10-11 12:17:13-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-10-11 12:17:39-04:00
log95242cc43132c7b6aeb2f7171389075859aba008
tree90794f4ef48e76764daf484ff3cc4def70902a76
parent8efcfeaf1e6db6e26d31132bbd2eb3317d9749bf

windows: workaround kernel race condition even more


2 files changed, 4 insertions(+), 4 deletions(-)

src/link.zig+2-2
...@@ -616,13 +616,13 @@ pub const File = struct {...@@ -616,13 +616,13 @@ pub const File = struct {
616 &coff.mf616 &coff.mf
617 else617 else
618 unreachable;618 unreachable;
619 mf.file = for (0..2) |_| break base.emit.root_dir.handle.openFile(base.emit.sub_path, .{619 mf.file = for (0..10) |_| break base.emit.root_dir.handle.openFile(base.emit.sub_path, .{
620 .mode = .read_write,620 .mode = .read_write,
621 }) catch |err| switch (err) {621 }) catch |err| switch (err) {
622 error.AccessDenied => switch (builtin.os.tag) {622 error.AccessDenied => switch (builtin.os.tag) {
623 .windows => {623 .windows => {
624 // give the kernel a chance to finish closing the executable handle624 // give the kernel a chance to finish closing the executable handle
625 std.os.windows.kernel32.Sleep(1);625 std.os.windows.kernel32.Sleep(10);
626 continue;626 continue;
627 },627 },
628 else => return error.AccessDenied,628 else => return error.AccessDenied,
test/standalone/windows_spawn/main.zig+2-2
...@@ -71,10 +71,10 @@ pub fn main() anyerror!void {...@@ -71,10 +71,10 @@ pub fn main() anyerror!void {
71 try testExec(allocator, "heLLo", "hello from exe\n");71 try testExec(allocator, "heLLo", "hello from exe\n");
7272
73 // now rename the exe to not have an extension73 // now rename the exe to not have an extension
74 for (0..2) |_| break tmp.dir.rename("hello.exe", "hello") catch |err| switch (err) {74 for (0..10) |_| break tmp.dir.rename("hello.exe", "hello") catch |err| switch (err) {
75 error.AccessDenied => {75 error.AccessDenied => {
76 // give the kernel a chance to finish closing the executable handle76 // give the kernel a chance to finish closing the executable handle
77 std.os.windows.kernel32.Sleep(1);77 std.os.windows.kernel32.Sleep(10);
78 continue;78 continue;
79 },79 },
80 else => |e| return e,80 else => |e| return e,