]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libfortran: Fix execute_command_line for Windows
authorTobias Burnus <tobias@codesourcery.com>
Wed, 18 Jan 2023 22:31:41 +0000 (23:31 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 18 Jan 2023 22:31:41 +0000 (23:31 +0100)
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.

libgfortran/intrinsics/execute_command_line.c

index 305f067d973b19360c2f8dc4010d906d9ac7c785..0d1688400c283cfe226efb3fa8b0aba35b3e651e 100644 (file)
@@ -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