summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-08-28 18:07:30 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-08-28 18:12:11 +0200
commitb1ba703f2ddb6707f5931faa88b4ad8a6c07a7e8 (patch)
tree21cd9e2d771e685ff6660692171feec43b604d2b
parentba5fbfe36fd9934398e8030253c4d0b87c81fd03 (diff)
Call _exit if execv fails in child process.
-rw-r--r--execute.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/execute.cc b/execute.cc
index bb691cf..bc4cd5f 100644
--- a/execute.cc
+++ b/execute.cc
@@ -66,6 +66,9 @@ int execute(const std::string& command,
if(pid == 0)
{
execv(command.data(), (char**)argv.data());
+ std::cout << "Could not execute " << command << ": " <<
+ strerror(errno) << "\n";
+ _exit(1); // execv only returns if an error occurred
}
auto ret = parent_waitpid(pid);
#elif 0