Kill external process, if node is canceled


Is there a method, that is applied, if the execution of a node is canceled. I would need such a method, because I want to start external processes from a node (using a ProcessBuilder). If the execution of the node is canceled, these externel processes continue running. I want to kill these external processes, if the remaining node is canceled.

Best Regards

Within your #execute() method, you need to catch a so-called CanceledExecutionException when calling #checkCanceled(). Within the catch/finally block do whatever need to be done with your external process.

Thank you, for your response.

I already tried using checkCanceled(), but I wasn't sure at which position within the execute() method checkCanceled() should be applied? Do you have a hint how to use checkCanceled() ?

Ups, sorry got it. The problem is that you have an external process running and need another process to test on #checkCanceled(). We have an external tool package containing several classes, such as ExtToolOutputNodeModel and CommandExecution. The latter holds an inner class CheckCanceledRunnable that does exactly what you need. You can also use the proposed NodeModel for your propose, I guess.