diff --git a/src/core/shards/process.cpp b/src/core/shards/process.cpp index fe74404e18..827fab1ad0 100644 --- a/src/core/shards/process.cpp +++ b/src/core/shards/process.cpp @@ -6,7 +6,6 @@ #endif #include "shared.hpp" -#include "async.hpp" // workaround for a boost bug.. #ifndef __kernel_entry @@ -23,6 +22,8 @@ #include #pragma clang diagnostic pop +#include "async.hpp" + namespace shards { namespace Process { struct Run { @@ -88,6 +89,7 @@ struct Run { void cleanup() { _arguments.cleanup(); } SHVar activate(SHContext *context, const SHVar &input) { + std::optional pCmd; return awaitne( context, [&]() { @@ -133,6 +135,8 @@ struct Run { boost::process::child cmd(exePath, argsArray, boost::process::std_out > ostr, boost::process::std_err > estr, boost::process::std_in < ipipe, ios); + pCmd = &cmd; + if (!ipipe) { throw ActivationError("Failed to open streams for child process"); } @@ -180,8 +184,10 @@ struct Run { return Var(_outBuf); } }, - [] { - // TODO CANCELLATION + [&] { + if(pCmd) { + (*pCmd)->terminate(); + } }); } };