# Interrupting execution

**URL:** https://discourse.julialang.org/t/interrupting-execution/72434
**Category:** General Usage
**Created:** [December 2, 2021, 7:44am UTC](https://discourse.julialang.org/t/interrupting-execution/72434 "2021-12-02T07:44:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [December 2, 2021, 7:44am UTC](https://discourse.julialang.org/t/interrupting-execution/72434/1 "2021-12-02T07:44:25Z")

</div>

I have read that julia only checks for IO and signals etc at certain points in the code. How was I able to interrupt this execution with ctrl-c? Where can I read the details?

```julia
julia> function f()
           while true
           end
       end
f (generic function with 1 method)
julia> @code_llvm f()
; @ REPL[1]:1 within `f'
; Function Attrs: noreturn
define nonnull {}* @julia_f_690() #0 {
top:
  br label %L1

L1: ; preds = %L1, %top
; @ REPL[1]:3 within `f'
  br label %L1
}

julia> f()
^C^C^C^C^C^C^CWARNING: Force throwing a SIGINT
ERROR: ^C^C^C^CInterruptException:^C
Stacktrace:
 [1] f()
   @ Main ./REPL[1]:3
 [2] top-level scope
   @ REPL[3]:1

```

---

<div class="post-metadata">

### Author: ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)
#### Post date: [December 2, 2021, 7:57am UTC](https://discourse.julialang.org/t/interrupting-execution/72434/2 "2021-12-02T07:57:35Z")

</div>

The story is different outside the REPL

```julia
matt@pig:~$ cat /tmp/t.jl
while true end
matt@pig:~$ julia /tmp/t.jl
^C
signal (2): Interrupt
in expression starting at /tmp/t.jl:1
pthread_cond_wait at /lib/x86_64-linux-gnu/libpthread.so.0 (unknown line)
uv_cond_wait at /workspace/srcdir/libuv/src/unix/thread.c:847
jl_task_get_next at /buildworker/worker/package_linux64/build/src/partr.c:508
poptask at ./task.jl:760
wait at ./task.jl:769
task_done_hook at ./task.jl:494
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
jl_finish_task at /buildworker/worker/package_linux64/build/src/task.c:208
jl_threadfun at /buildworker/worker/package_linux64/build/src/partr.c:264
start_thread at /lib/x86_64-linux-gnu/libpthread.so.0 (unknown line)
clone at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: (nil))

... snip the call stack, it is too big to post! ...

_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
exec_options at ./client.jl:285
_start at ./client.jl:485
jfptr__start_43689.clone_1 at /opt/julia-1.6.3/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
true_main at /buildworker/worker/package_linux64/build/src/jlapi.c:560
repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:702
main at julia (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4007d8)
unknown function (ip: (nil))
Allocations: 607501 (Pool: 606982; Big: 519); GC: 1

```

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [December 2, 2021, 8:16am UTC](https://discourse.julialang.org/t/interrupting-execution/72434/3 "2021-12-02T08:16:35Z")

</div>

It also interrupts outside the repl for me.

```julia
% echo 'function f() while true end end; f()' > 1.jl 
% julia 1.jl 
^C
signal (2): Interrupt
in expression starting at /tmp/tmp.rWqqM4iP2I/1.jl:1
f at /tmp/tmp.rWqqM4iP2I/1.jl:1
unknown function (ip: 0x7feb171e68ec)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
unknown function (ip: (nil))
unknown function (ip: (nil))
Allocations: 628874 (Pool: 628476; Big: 398); GC: 1

```

---

<div class="post-metadata">

### Author: ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)
#### Post date: [December 2, 2021, 8:51am UTC](https://discourse.julialang.org/t/interrupting-execution/72434/4 "2021-12-02T08:51:55Z")

</div>

Hmm, if I leave it to run, it is uninterruptible until I give it a ^Z

```julia
matt@pig:~/bin$ julia /tmp/t.jl
^C^C^C^C^C^C^C^C^C^Z

```

And this behaviour is different, it is uninterruptible … unless I press multiple ^C in quick succession

```julia
matt@pig:~/bin$ julia -e "while true end"
^C^C^C^C^C^C^C^C^C^C^CWARNING: Force throwing a SIGINT
ERROR: ^CInterruptException:
Stacktrace:
 [1] top-level scope
   @ ./none:1

```

---

<div class="post-metadata">

### Author: ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)
#### Post date: [December 2, 2021, 11:07am UTC](https://discourse.julialang.org/t/interrupting-execution/72434/5 "2021-12-02T11:07:14Z")

</div>

There are new tickets about Julia 1.7.0 ignoring signals

> [@Julia 1.7.0 ignores SIGTERMs (Signal 15)](https://discourse.julialang.org/t/julia-1-7-0-ignores-sigterms-signal-15/72357/5):
>
> Oh I see… Should I open an issue on the repo? Or probably it will be fixed anyway, if it is in the latest commit, right?
