From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 32ED53858288; Wed, 18 Jan 2023 22:32:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32ED53858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674081127; bh=Fb2feAde0qYCMLZjNP2eIVRMtZGR/ti2RYoEkzlU8AE=; h=From:To:Subject:Date:From; b=gLMxDK7ICPb9D0nL13LdMAs2DK79cH/4jwqfNp6m/Ksk2CfJAqOdDylcVGnGDUkKU m7Kx7Zsd004ni23sdwds4HuCGuH4kqBN2bvZVTtwlJu0D96yp5yjVtgYnGPHVHiEHG X2LuaF0RptVP33g/8DAnk9L9g0Hu9N/r9EiUFYaU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5250] libfortran: Fix execute_command_line for Windows X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/master X-Git-Oldrev: 0f85ae6591c92b161693073c0931c7ca1d5d0c5a X-Git-Newrev: 8e2c6e7b426b6c9c13076208b2e176d4aa1432f1 Message-Id: <20230118223207.32ED53858288@sourceware.org> Date: Wed, 18 Jan 2023 22:32:07 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8e2c6e7b426b6c9c13076208b2e176d4aa1432f1 commit r13-5250-g8e2c6e7b426b6c9c13076208b2e176d4aa1432f1 Author: Tobias Burnus Date: Wed Jan 18 23:31:41 2023 +0100 libfortran: Fix execute_command_line for Windows On Windows, 'system' is called - that fails with -1 if the command interpreter could not be started; on POSIX systems, if the child process could not be started by the shell, exit(127)/_exit(127) is called/returned. On Windows, cmd.exe (and also the PowerShell) return errorlevel 9009. libgfortran/ChangeLog: * intrinsics/execute_command_line.c (execute_command_line): On Windows, regard system()'s return value of 9009 as EXEC_INVALIDCOMMAND. Diff: --- libgfortran/intrinsics/execute_command_line.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libgfortran/intrinsics/execute_command_line.c b/libgfortran/intrinsics/execute_command_line.c index 305f067d973..0d1688400c2 100644 --- a/libgfortran/intrinsics/execute_command_line.c +++ b/libgfortran/intrinsics/execute_command_line.c @@ -144,6 +144,11 @@ execute_command_line (const char *command, bool wait, int *exitstat, #if defined(WEXITSTATUS) && defined(WIFEXITED) || (WIFEXITED(res) && WEXITSTATUS(res) == 127) || (WIFEXITED(res) && WEXITSTATUS(res) == 126) +#endif +#ifdef __MINGW32__ + /* cmd.exe sets the errorlevel to 9009, + if the command could not be executed. */ + || res == 9009 #endif ) /* Shell return codes 126 and 127 mean that the command line could