aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libutil/processes.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libutil/processes.cc b/src/libutil/processes.cc
index 05b1321e9..866ba9647 100644
--- a/src/libutil/processes.cc
+++ b/src/libutil/processes.cc
@@ -280,9 +280,14 @@ RunningProgram::~RunningProgram()
void RunningProgram::wait()
{
- int status = pid.wait();
- if (status)
- throw ExecError(status, "program '%1%' %2%", program, statusToString(status));
+ if (std::uncaught_exceptions() == 0) {
+ int status = pid.wait();
+ if (status)
+ throw ExecError(status, "program '%1%' %2%", program, statusToString(status));
+ } else {
+ pid.kill();
+ debug("killed subprocess %1% during exception handling", program);
+ }
}
RunningProgram runProgram2(const RunOptions & options)