Skip to content

Commit 633b0c4

Browse files
committed
[flang] Fix execute_command_line cmdstat is not set when error occurs
Fixes: #92929
1 parent c5aeca7 commit 633b0c4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

flang/docs/Intrinsics.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,6 @@ used in constant expressions have currently no folding support at all.
899899
- 1: Fork Error (occurs only on POSIX-compatible systems).
900900
- 2: Execution Error (command exits with status -1).
901901
- 3: Invalid Command Error (determined by the exit code depending on the system).
902-
- On Windows: exit code is 1.
903-
- On POSIX-compatible systems: exit code is 127 or 126.
904902
- 4: Signal error (either stopped or killed by signal, occurs only on POSIX-compatible systems).
905903
- 0: Otherwise.
906904
- Asynchronous execution:

flang/runtime/execute.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ int TerminationCheck(int status, const Descriptor *cmdstat,
7272
CheckAndCopyCharsToDescriptor(cmdmsg, "Execution error");
7373
}
7474
}
75+
7576
#ifdef _WIN32
7677
// On WIN32 API std::system returns exit status directly
7778
int exitStatusVal{status};
78-
if (exitStatusVal == 1) {
7979
#else
8080
int exitStatusVal{WEXITSTATUS(status)};
81-
if (exitStatusVal == 127 || exitStatusVal == 126) {
8281
#endif
82+
if (exitStatusVal != 0) {
8383
if (!cmdstat) {
8484
terminator.Crash(
8585
"Invalid command quit with exit status code: %d", exitStatusVal);
@@ -88,23 +88,25 @@ int TerminationCheck(int status, const Descriptor *cmdstat,
8888
CheckAndCopyCharsToDescriptor(cmdmsg, "Invalid command line");
8989
}
9090
}
91+
9192
#if defined(WIFSIGNALED) && defined(WTERMSIG)
9293
if (WIFSIGNALED(status)) {
9394
if (!cmdstat) {
94-
terminator.Crash("killed by signal: %d", WTERMSIG(status));
95+
terminator.Crash("Killed by signal: %d", WTERMSIG(status));
9596
} else {
9697
StoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
97-
CheckAndCopyCharsToDescriptor(cmdmsg, "killed by signal");
98+
CheckAndCopyCharsToDescriptor(cmdmsg, "Killed by signal");
9899
}
99100
}
100101
#endif
102+
101103
#if defined(WIFSTOPPED) && defined(WSTOPSIG)
102104
if (WIFSTOPPED(status)) {
103105
if (!cmdstat) {
104-
terminator.Crash("stopped by signal: %d", WSTOPSIG(status));
106+
terminator.Crash("Stopped by signal: %d", WSTOPSIG(status));
105107
} else {
106108
StoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
107-
CheckAndCopyCharsToDescriptor(cmdmsg, "stopped by signal");
109+
CheckAndCopyCharsToDescriptor(cmdmsg, "Stopped by signal");
108110
}
109111
}
110112
#endif

0 commit comments

Comments
 (0)