From eb02e5bba2df7d3daceb4b1fc1d6c58fddf1f238 Mon Sep 17 00:00:00 2001 From: Cedric Delamarre Date: Tue, 26 May 2015 15:47:37 +0200 Subject: [PATCH] Windows command.temp EACCES error. host start 1+1 // scilab crash because of NULL FILE* return by fopen host start // then close window 1+1 // work The process was created as inherit process of Scilab, so TMPDIR was locked by this process. Change-Id: Iae0923e227c769f114d06b72ad03137fc5ddacde --- scilab/modules/ast/src/cpp/parse/parser.cpp | 15 ++++++++++++++- .../src/c/scilab_windows/spawncommand.c | 6 +----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/scilab/modules/ast/src/cpp/parse/parser.cpp b/scilab/modules/ast/src/cpp/parse/parser.cpp index ddde74a..0754b45 100644 --- a/scilab/modules/ast/src/cpp/parse/parser.cpp +++ b/scilab/modules/ast/src/cpp/parse/parser.cpp @@ -165,7 +165,20 @@ void ParserSingleInstance::parse(char *command) fclose(fileLocker); } - fopen_s(&yyin, szFile, "w"); + errno_t err; + err = fopen_s(&yyin, szFile, "w"); + if (err) + { + ParserSingleInstance::setExitStatus(Parser::Failed); + ParserSingleInstance::resetErrorMessage(); + wchar_t szError[bsiz]; + wchar_t* wszFile = to_wide_string(szFile); + os_swprintf(szError, bsiz, _W("%ls: Cannot open file %ls.\n").c_str(), L"parser", wszFile); + FREE(wszFile); + appendErrorMessage(szError); + return; + } + fwrite(command, sizeof(char), len, yyin); fclose(yyin); fopen_s(&yyin, szFile, "r"); diff --git a/scilab/modules/windows_tools/src/c/scilab_windows/spawncommand.c b/scilab/modules/windows_tools/src/c/scilab_windows/spawncommand.c index 7a3713f..3332f09 100644 --- a/scilab/modules/windows_tools/src/c/scilab_windows/spawncommand.c +++ b/scilab/modules/windows_tools/src/c/scilab_windows/spawncommand.c @@ -498,10 +498,6 @@ int CallWindowsShellW(wchar_t* _pstCommand) return 1; } - saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; - ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); @@ -526,7 +522,7 @@ int CallWindowsShellW(wchar_t* _pstCommand) CmdLine = (wchar_t*)MALLOC(iCmdSize * sizeof(wchar_t)); os_swprintf(CmdLine, iCmdSize, L"%ls /a /c \"%ls\" && echo DOS>%ls", shellCmd, _pstCommand, FileTMPDir); - if (CreateProcessW(NULL, CmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &siStartInfo, &piProcInfo)) + if (CreateProcessW(NULL, CmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &siStartInfo, &piProcInfo)) { WaitForSingleObject(piProcInfo.hProcess, INFINITE); -- 1.7.9.5