diff options
author | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-08-23 21:24:49 +0000 |
---|---|---|
committer | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-08-23 21:24:49 +0000 |
commit | c7cce8c0f40c1ff1c0b887222ffb01ba39e0797f (patch) | |
tree | 22c06ca665153780f25817897e0ceb0f60166df8 /libgfortran/intrinsics | |
parent | a537037b8e9f4ca6e53e947adc156f023f8acff7 (diff) | |
download | gcc-c7cce8c0f40c1ff1c0b887222ffb01ba39e0797f.tar.gz |
PR libfortran/62296
* intrinsics/execute_command_line.c (EXEC_INVALIDCOMMAND): New
error code.
(cmdmsg_values): New error message.
(set_cmdstat): Rework runtime error.
(execute_command_line): Handle invalid command line error status.
* gfortran.dg/execute_command_line_2.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227105 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics')
-rw-r--r-- | libgfortran/intrinsics/execute_command_line.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libgfortran/intrinsics/execute_command_line.c b/libgfortran/intrinsics/execute_command_line.c index 404314b0952..5af9efd7946 100644 --- a/libgfortran/intrinsics/execute_command_line.c +++ b/libgfortran/intrinsics/execute_command_line.c @@ -36,11 +36,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see enum { EXEC_SYNCHRONOUS = -2, EXEC_NOERROR = 0, EXEC_SYSTEMFAILED, - EXEC_CHILDFAILED }; + EXEC_CHILDFAILED, EXEC_INVALIDCOMMAND }; static const char *cmdmsg_values[] = { "", "Termination status of the command-language interpreter cannot be obtained", - "Execution of child process impossible" }; + "Execution of child process impossible", + "Invalid command line" }; @@ -50,7 +51,12 @@ set_cmdstat (int *cmdstat, int value) if (cmdstat) *cmdstat = value; else if (value > EXEC_NOERROR) - runtime_error ("Could not execute command line"); + { +#define MSGLEN 200 + char msg[MSGLEN] = "EXECUTE_COMMAND_LINE: "; + strncat (msg, cmdmsg_values[value], MSGLEN - strlen(msg) - 1); + runtime_error (msg); + } } @@ -95,6 +101,15 @@ execute_command_line (const char *command, bool wait, int *exitstat, else if (!wait) set_cmdstat (cmdstat, EXEC_SYNCHRONOUS); #endif + else if (res == 127 || res == 126 +#if defined(WEXITSTATUS) && defined(WIFEXITED) + || (WIFEXITED(res) && WEXITSTATUS(res) == 127) + || (WIFEXITED(res) && WEXITSTATUS(res) == 126) +#endif + ) + /* Shell return codes 126 and 127 mean that the command line could + not be executed for various reasons. */ + set_cmdstat (cmdstat, EXEC_INVALIDCOMMAND); else set_cmdstat (cmdstat, EXEC_NOERROR); |