authorgravatar for strangebug@ineedtojet.comStrangeBug <strangebug@ineedtojet.com> 2020-05-22 20:24:16+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-19 20:49:25-07:00
log59711becc74911ba251001de81bbac2a53e81b9f
tree982cd513dff0a2bf36633ca9c3bbd88d27184992
parentb1c7334355b345a6c244f617c2d4fae9e9f82c5a

Add handler for INVALID_HANDLE to prevent infinite loop when stderr is not available.


2 files changed, 5 insertions(+), 0 deletions(-)

lib/std/os/windows.zig+2
...@@ -469,6 +469,7 @@ pub const WriteFileError = error{...@@ -469,6 +469,7 @@ pub const WriteFileError = error{
469 SystemResources,469 SystemResources,
470 OperationAborted,470 OperationAborted,
471 BrokenPipe,471 BrokenPipe,
472 InvalidFd,
472 Unexpected,473 Unexpected,
473};474};
474475
...@@ -542,6 +543,7 @@ pub fn WriteFile(...@@ -542,6 +543,7 @@ pub fn WriteFile(
542 .NOT_ENOUGH_QUOTA => return error.SystemResources,543 .NOT_ENOUGH_QUOTA => return error.SystemResources,
543 .IO_PENDING => unreachable,544 .IO_PENDING => unreachable,
544 .BROKEN_PIPE => return error.BrokenPipe,545 .BROKEN_PIPE => return error.BrokenPipe,
546 .INVALID_HANDLE => return error.NotOpenForWriting,
545 else => |err| return unexpectedError(err),547 else => |err| return unexpectedError(err),
546 }548 }
547 }549 }
src-self-hosted/stage2.zig+3
...@@ -164,6 +164,7 @@ export fn stage2_render_ast(tree: *ast.Tree, output_file: *FILE) Error {...@@ -164,6 +164,7 @@ export fn stage2_render_ast(tree: *ast.Tree, output_file: *FILE) Error {
164 error.OutOfMemory => return .OutOfMemory,164 error.OutOfMemory => return .OutOfMemory,
165 error.Unexpected => return .Unexpected,165 error.Unexpected => return .Unexpected,
166 error.InputOutput => return .FileSystem,166 error.InputOutput => return .FileSystem,
167 error.InvalidFd => return .FileSystem,
167 };168 };
168 return .None;169 return .None;
169}170}
...@@ -635,6 +636,7 @@ export fn stage2_libc_parse(stage1_libc: *Stage2LibCInstallation, libc_file_z: [...@@ -635,6 +636,7 @@ export fn stage2_libc_parse(stage1_libc: *Stage2LibCInstallation, libc_file_z: [
635 error.NotDir => return .NotDir,636 error.NotDir => return .NotDir,
636 error.DeviceBusy => return .DeviceBusy,637 error.DeviceBusy => return .DeviceBusy,
637 error.FileLocksNotSupported => unreachable,638 error.FileLocksNotSupported => unreachable,
639 error.InvalidFd => return .FileSystem,
638 };640 };
639 stage1_libc.initFromStage2(libc);641 stage1_libc.initFromStage2(libc);
640 return .None;642 return .None;
...@@ -679,6 +681,7 @@ export fn stage2_libc_render(stage1_libc: *Stage2LibCInstallation, output_file:...@@ -679,6 +681,7 @@ export fn stage2_libc_render(stage1_libc: *Stage2LibCInstallation, output_file:
679 error.AccessDenied => return .AccessDenied,681 error.AccessDenied => return .AccessDenied,
680 error.Unexpected => return .Unexpected,682 error.Unexpected => return .Unexpected,
681 error.InputOutput => return .FileSystem,683 error.InputOutput => return .FileSystem,
684 error.InvalidFd => return .FileSystem,
682 };685 };
683 return .None;686 return .None;
684}687}