# Terminating a process on Windows

**URL:** <https://discourse.julialang.org/t/terminating-a-process-on-windows/87481>\
**Category:** General Usage\
**Tags:** shell, pipelines\
**Created:** [September 19, 2022, 3:53pm UTC](https://discourse.julialang.org/t/terminating-a-process-on-windows/87481 "2022-09-19T15:53:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Ashlin\_Harris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ashlin_harris/32/210166_2.png) [@Ashlin\_Harris](https://discourse.julialang.org/u/Ashlin_Harris)\
**Post date:** [April 21, 2023, 8:26pm UTC](https://discourse.julialang.org/t/terminating-a-process-on-windows/87481/2 "2023-04-21T20:26:41Z")

</div>

[This thread](https://discourse.julialang.org/t/how-do-i-kill-a-spawned-process/3824) seems be related.

I found [this workaround](https://discourse.julialang.org/t/update-stdout-while-a-function-is-running/86285/9):

```julia
begin
  # Command for drawing a spinner
  command = "
    t=Threads.@async read(stdin, Char)
    while !istaskdone(t)
      for q=['\\\\','|','/','-']
        print('\b',q)
        sleep(0.1)
      end
    end
    exit()"

  # Draw spinner as a separate process
  proc_input = Pipe();
  proc = run(pipeline(`julia -e $command`,stdin = proc_input, stdout = stdout), wait = false)

  sleep(1)
  kill(proc) # Process is signaled, but it keeps running
  sleep(2)
  write(proc_input,'c') # Process finishes when it reads from its stdin
  sleep(0.5)
  println()
end

```

Instead of relying on `kill()`, the main process writes to the `stdin` of the spawned process, and this is interpreted as a sort of kill signal.

In practice, the main drawback is that I haven’t found any way for the spawned process to receive signals both from the user and from the main process.

---

_[View the full topic](https://discourse.julialang.org/t/terminating-a-process-on-windows/87481)._
