# Run computation in separate process and kill it after a time limit

I am looking for a solution to run a Mathematica calculation in a separate process (separate kernel) and cancel the computation after a given time. If it cannot be cancelled, then just kill that process gracefully.

There are two easy ways to evaluate code in a separate kernel: parallel kernels and LocalSubmit. What I am looking for is a mechanism to gracefully kill the kernel after a timeout if a soft-abort does not work.

The SageMath system has a feature like this: see @fork.

• There are ways I can think of to do this, but they would all require me to re-implement the inter-kernel communication myself, which is a lot of work. I posted this question to see if there are some built-in ways that are simpler and what I missed. – Szabolcs Oct 30 '19 at 12:13
• You can be interested in: (1), (2). – Alexey Popkov Oct 30 '19 at 13:30