浏览代码

Don't treat failure to open NUL device as fatal error (based on #467)

Jordan Russell 1 年之前
父节点
当前提交
cf85ddc5a6
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      Projects/Src/CmnFunc2.pas

+ 7 - 2
Projects/Src/CmnFunc2.pas

@@ -1655,9 +1655,14 @@ begin
     FILE_SHARE_READ or FILE_SHARE_WRITE, @SecurityAttributes,
     OPEN_EXISTING, 0, 0);
   if NulDevice = INVALID_HANDLE_VALUE then
-    raise Exception.CreateFmt('Output redirection error: CreateFile failed (%d)', [GetLastError]);
+    { In case the NUL device is missing (which it inexplicably seems to
+      be for some users, per web search), don't treat it as a fatal
+      error. Just leave FStdInNulDevice at 0. It's not ideal, but the
+      child process likely won't even attempt to access stdin anyway. }
+    LogErrorFmt('Failed to open NUL device (%d). Will pass NULL handle for stdin.', [GetLastError])
+  else
+    FStdInNulDevice := NulDevice;
 
-  FStdInNulDevice := NulDevice;
   PipeCreate(FStdOutPipeRead, FStdOutPipeWrite, SecurityAttributes);
 
   if FMode = omCapture then