Skip to content

Return FileNotFound when CreateProcessW is called with a missing path #23567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/std/os/windows.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,7 @@ pub fn CreateProcessW(
switch (GetLastError()) {
.FILE_NOT_FOUND => return error.FileNotFound,
.PATH_NOT_FOUND => return error.FileNotFound,
.DIRECTORY => return error.FileNotFound,
.ACCESS_DENIED => return error.AccessDenied,
.INVALID_PARAMETER => unreachable,
.INVALID_NAME => return error.InvalidName,
Expand Down
2 changes: 2 additions & 0 deletions test/standalone/windows_spawn/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub fn main() anyerror!void {
try testExec(allocator, "HeLLo.exe", "hello from exe\n");
// without extension should find the .exe (case insensitive)
try testExec(allocator, "heLLo", "hello from exe\n");
// with invalid cwd
try std.testing.expectError(error.FileNotFound, testExecWithCwd(allocator, "hello.exe", "missing_dir", ""));

// now add a .bat
try tmp.dir.writeFile(.{ .sub_path = "hello.bat", .data = "@echo hello from bat" });
Expand Down