# Kill a (distributed) child process

**URL:** <https://discourse.julialang.org/t/kill-a-distributed-child-process/94322>\
**Category:** General Usage\
**Created:** [February 9, 2023, 2:07am UTC](https://discourse.julialang.org/t/kill-a-distributed-child-process/94322 "2023-02-09T02:07:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![torrance](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torrance/32/38990_2.png) [@torrance](https://discourse.julialang.org/u/torrance)\
**Post date:** [February 9, 2023, 2:07am UTC](https://discourse.julialang.org/t/kill-a-distributed-child-process/94322/1 "2023-02-09T02:07:50Z")

</div>

Let’s say I’ve spawned a distributed process, and this process has made a particular `ccall` that, for whatever reason, refuses to die from a standard call to `interrupt()`. e.g. the following fails:

```julia
using Distributed

addprocs(1)

f = @spawnat 2 begin
    @ccall sleep(20::Int)::Int # Pretend this is an uninterruptible C call
end

println("Waiting...")
interrupt(2)
fetch(f)

```

I don’t control the C code, and I’m not 100% sure why it won’t interrupt. However, it _can_ be killed (i.e. kill -9) works just fine.

My question: what’s a nice way to send a SIGKILL signal to the child process?

---

<div class="post-metadata">

**Author:** ![torrance](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torrance/32/38990_2.png) [@torrance](https://discourse.julialang.org/u/torrance)\
**Post date:** [February 9, 2023, 2:28am UTC](https://discourse.julialang.org/t/kill-a-distributed-child-process/94322/2 "2023-02-09T02:28:43Z")

</div>

To reply to myself, this does work - however I’m using non-public/non-stable method from within Distributed to get the `::Process` of the worker:

```julia
w = Distributed.worker_from_id(2)
kill(w.config.process, Base.SIGKILL)

```

Is there a way to get the worker process object without raiding internal variables?

---

<div class="post-metadata">

**Author:** ![torrance](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torrance/32/38990_2.png) [@torrance](https://discourse.julialang.org/u/torrance)\
**Post date:** [February 9, 2023, 5:13am UTC](https://discourse.julialang.org/t/kill-a-distributed-child-process/94322/3 "2023-02-09T05:13:02Z")

</div>

For reference, there’s a PR ([[Distributed] `kill(::LocalManager, ...)` should actually call `kill()` by staticfloat · Pull Request #45801 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/45801)) for this issue that appears to have stalled. If it is eventually merged, the right way to do this would be via `rmprocs(pid)`.
