From 4928f6986744fe3762399145991f139464b308f1 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Sat, 29 Jul 2017 16:25:06 +0000 Subject: [PATCH 1/2] Diagnostic output if run/execve fails --- regression/goto-gcc/run_diagnostic/main.i | 4 ++++ regression/goto-gcc/run_diagnostic/test.desc | 9 +++++++++ src/util/run.cpp | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 regression/goto-gcc/run_diagnostic/main.i create mode 100644 regression/goto-gcc/run_diagnostic/test.desc diff --git a/regression/goto-gcc/run_diagnostic/main.i b/regression/goto-gcc/run_diagnostic/main.i new file mode 100644 index 00000000000..f8b643afbf2 --- /dev/null +++ b/regression/goto-gcc/run_diagnostic/main.i @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/regression/goto-gcc/run_diagnostic/test.desc b/regression/goto-gcc/run_diagnostic/test.desc new file mode 100644 index 00000000000..a7e89e4b7be --- /dev/null +++ b/regression/goto-gcc/run_diagnostic/test.desc @@ -0,0 +1,9 @@ +CORE +main.i +--native-compiler /no/such/tool +^EXIT=1$ +^SIGNAL=0$ +^execvp /no/such/tool failed: No such file or directory$ +-- +^warning: ignoring +^CONVERSION ERROR$ diff --git a/src/util/run.cpp b/src/util/run.cpp index f106309002e..217d7f8d226 100644 --- a/src/util/run.cpp +++ b/src/util/run.cpp @@ -127,9 +127,12 @@ int run( dup2(stdin_fd, STDIN_FILENO); if(stdout_fd!=STDOUT_FILENO) dup2(stdout_fd, STDOUT_FILENO); + + errno=0; execvp(what.c_str(), _argv.data()); /* usually no return */ + perror(std::string("execvp "+what+" failed").c_str()); return 1; } else /* fork() returns new pid to the parent process */ From 08a4077c100aca8c226e8ad9fc1c3e14b5eb4a37 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Fri, 8 Sep 2017 09:39:11 +0100 Subject: [PATCH 2/2] Make the child process that failed to execvp exit Previously the zombie child would continue on the same code path as the forking parent. Hence one would see spurious "Remove failed" message as the zombie child would try to perform the same file removal as the parent. --- regression/goto-gcc/run_diagnostic/test.desc | 1 + src/util/run.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/regression/goto-gcc/run_diagnostic/test.desc b/regression/goto-gcc/run_diagnostic/test.desc index a7e89e4b7be..e3a632f65f2 100644 --- a/regression/goto-gcc/run_diagnostic/test.desc +++ b/regression/goto-gcc/run_diagnostic/test.desc @@ -5,5 +5,6 @@ main.i ^SIGNAL=0$ ^execvp /no/such/tool failed: No such file or directory$ -- +^Remove failed ^warning: ignoring ^CONVERSION ERROR$ diff --git a/src/util/run.cpp b/src/util/run.cpp index 217d7f8d226..d0fddab27fd 100644 --- a/src/util/run.cpp +++ b/src/util/run.cpp @@ -133,7 +133,7 @@ int run( /* usually no return */ perror(std::string("execvp "+what+" failed").c_str()); - return 1; + exit(1); } else /* fork() returns new pid to the parent process */ {