Procházet zdrojové kódy

删除无用代码;

scbc.sat2 před 5 roky
rodič
revize
bf281945ea
1 změnil soubory, kde provedl 2 přidání a 22 odebrání
  1. 2 22
      RunPython/RunPython/ScriptExecutor.cpp

+ 2 - 22
RunPython/RunPython/ScriptExecutor.cpp

@@ -156,16 +156,6 @@ int CScriptExecutor::RedirectStdout(LPSTARTUPINFO si /*=NULL*/)
 	}
 	else if (m_nRunType == EMBEDDED)
 	{
-#if 0 // 无法实现转发;
-		FILE *stream;
-		if((stream = freopen(m_szLogPath, "w", stdout)) == NULL)
-			return -1;
-#else
-		SECURITY_ATTRIBUTES sa;
-		sa.bInheritHandle = TRUE;
-		sa.lpSecurityDescriptor = NULL;
-		sa.nLength = sizeof(sa);
-
 		// 创建stdout的管道;
 		if (!CreatePipe(&m_hStdOutRead, &m_hStdOutWrite, NULL, 0))
 		{
@@ -175,32 +165,22 @@ int CScriptExecutor::RedirectStdout(LPSTARTUPINFO si /*=NULL*/)
 
 		// 将 C 运行时文件描述符与现有操作系统文件句柄关联;
 		int wpfd = _open_osfhandle((intptr_t)m_hStdOutWrite, _O_TEXT);
-#if 0
-		FILE* pOutFile = _fdopen(wpfd, "w");
-		*stdout = *pOutFile;
-		setvbuf(stdout, NULL, _IONBF, 0);
-
-		if (!SetStdHandle(STD_OUTPUT_HANDLE, m_hStdOutWrite))
-		{
-			printf("Error:重定向失败\n");
-		}
-#else
 		// 为stdout分配新文件描述符;
 		if (_dup2(wpfd, _fileno(stdout)) != 0)
 		{
 			printf("Error:dup2调用失败");
+			return -2;
 		}
 		_close(wpfd);
 
 		if (!SetStdHandle(STD_OUTPUT_HANDLE, m_hStdOutWrite))
 		{
 			printf("Error:重定向失败\n");
+			return -3;
 		}
 
 		// 设置标准流不使用缓冲,即时写入;
 		setvbuf(stdout, NULL, _IONBF, 0);
-#endif
-#endif
 
 		return 0;
 	}