# Interrupt with Ctrl+c not working

**URL:** <https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361>\
**Category:** General Usage\
**Created:** [November 28, 2017, 4:46pm UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361 "2017-11-28T16:46:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [November 28, 2017, 4:46pm UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361/1 "2017-11-28T16:46:15Z")

</div>

Is there any reason why I can’t interrupt my code with Ctrl+c sometimes?  
It doesn’t seem to work with parallel stuff where I can use Ctrl+d to interrupt but in my case it doesn’t work at all.  
Added some stuff to my code maybe you have an idea what kind of behavior can cause this.

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [November 28, 2017, 7:41pm UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361/2 "2017-11-28T19:41:15Z")

</div>

One case is code with `try` blocks, this will not interrupt:

```julia
for i=1:10
    try
        info(i)
        sleep(1)
    catch err
        warn(err)
    end
end

```

Which can be fixed by adding

`typeof(err) == InterruptException && rethrow(err)`

---

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [November 29, 2017, 12:35am UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361/3 "2017-11-29T00:35:44Z")

</div>

Good to know. I don’t have a try and catch block 😕  
Actually I’m adding a part to my program which runs at the beginning and I can’t break even if the new part finished already, which seems to be super weird to me.

---

<div class="post-metadata">

**Author:** ![Stephen\_Vavasis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephen_vavasis/32/3389_2.png) [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Post date:** [November 29, 2017, 4:18am UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361/4 "2017-11-29T04:18:24Z")

</div>

In Julia 0.6 running under Windows 10, I have found that I cannot interrupt with ctrl-C once PyPlot is loaded (e.g., a file with a `using PyPlot.plot` statement gets executed). Instead, the ctrl-c goes into a queue somewhere, and finally is acted upon when a plot is actually made. I reported this problem here:

[https://github.com/JuliaPy/PyPlot.jl/issues/305](https://github.com/JuliaPy/PyPlot.jl/issues/305)

but as far as I know the issue is still open.

---

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [November 29, 2017, 4:24am UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361/5 "2017-11-29T04:24:25Z")

</div>

hmm okay. That seems weird as well.  
I think the really strange part in my case that all the new stuff finished and I still can’t interrupt. And I have no weird stuff added in my opinion. No try catch, to extra libraries (besides GLPK) which seems to run normal.

---

<div class="post-metadata">

**Author:** ![anon61610682](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@anon61610682](https://discourse.julialang.org/u/anon61610682)\
**Post date:** [November 29, 2017, 12:42pm UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361/6 "2017-11-29T12:42:02Z")

</div>

When I am running my code on a (Linux) server from the terminal (most often, parallel code), I cannot `kill` a stalled `Julia` (worker) process, either, if I use `TERM` (terminate) or `INT` (interrupt). Then, I simply use the `HUP` (hangup) signal, which is always successful. Not sure though, if this is specific to parallel processes. If that is the case for you, it may be worth keeping in mind.

---

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [November 29, 2017, 4:10pm UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361/7 "2017-11-29T16:10:56Z")

</div>

Well I can kill it via killall julia at anytime but I don’t want to get out of the julia REPL.

---

<div class="post-metadata">

**Author:** ![anon61610682](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@anon61610682](https://discourse.julialang.org/u/anon61610682)\
**Post date:** [November 29, 2017, 4:54pm UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361/8 "2017-11-29T16:54:34Z")

</div>

Lucky you, then. When I have the problem with some parallel workers, `killall --process-group julia` does not help me unless I specifically send the `HUP` signal — that’s why I wanted to write the above message when I saw the `CTRL-c` key sequence.

---

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [November 29, 2017, 5:02pm UTC](https://discourse.julialang.org/t/interrupt-with-ctrl-c-not-working/7361/9 "2017-11-29T17:02:30Z")

</div>

Okay that seems totally strange and yeah more annoying then my issue 😃
