# What makes a function interruptible with ctrl+c?

**URL:** https://discourse.julialang.org/t/what-makes-a-function-interruptible-with-ctrl-c/86625
**Category:** General Usage
**Created:** [September 1, 2022, 4:23am UTC](https://discourse.julialang.org/t/what-makes-a-function-interruptible-with-ctrl-c/86625 "2022-09-01T04:23:36Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)
#### Post date: [September 1, 2022, 6:52am UTC](https://discourse.julialang.org/t/what-makes-a-function-interruptible-with-ctrl-c/86625/2 "2022-09-01T06:52:18Z")

</div>

That’s a good question. Generally you can “try” to catch it using something like this:

```julia
    try
        ...
    catch err
        if typeof(err) == InterruptException
           ...
        end
    end

```

but it was always unpredictable in the past and it is still confusing (at least to me) in 1.8.0, see e.g.

- [Cannot safely exit Pluto on Windows + git bash · Issue #2136 · fonsp/Pluto.jl · GitHub](https://github.com/fonsp/Pluto.jl/issues/2136)
- [Ctrl-C in script: atexit is ignored](https://discourse.julialang.org/t/ctrl-c-in-script-atexit-is-ignored/82413)
- [Cannot catch Ctrl-C gracefully in this script - #4 by chunjiw](https://discourse.julialang.org/t/cannot-catch-ctrl-c-gracefully-in-this-script/79757/4)

and so on.

The problem is – as far as I understood – that the SIGINT is sometimes hold back by some other code which may prevent to reach your desired try-catch. It may even end up in nirvana so that the `InterruptException` is never bubbling up, although all background tasks have finished and the program is in an idle state waiting for any kind of input whatsoever.

I remember some discussions many years ago where more details were revealed but I cannot find them. Performance is btw. one of the reasons you cannot have instant interruption, since you would need to regularly check for signals during runtime, so it’s always a trade-off between those.

---

_[View the full topic](https://discourse.julialang.org/t/what-makes-a-function-interruptible-with-ctrl-c/86625)._
