Skip to content

Commit

Permalink
try fix process + cancelation
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkingsugar committed Feb 21, 2023
1 parent 128309a commit 1d1ec55
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core/shards/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#endif

#include "shared.hpp"
#include "async.hpp"

// workaround for a boost bug..
#ifndef __kernel_entry
Expand All @@ -23,6 +22,8 @@
#include <string>
#pragma clang diagnostic pop

#include "async.hpp"

namespace shards {
namespace Process {
struct Run {
Expand Down Expand Up @@ -88,6 +89,7 @@ struct Run {
void cleanup() { _arguments.cleanup(); }

SHVar activate(SHContext *context, const SHVar &input) {
std::optional<boost::process::child*> pCmd;
return awaitne(
context,
[&]() {
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -180,8 +184,10 @@ struct Run {
return Var(_outBuf);
}
},
[] {
// TODO CANCELLATION
[&] {
if(pCmd) {
(*pCmd)->terminate();
}
});
}
};
Expand Down

0 comments on commit 1d1ec55

Please sign in to comment.