# How do I break out of an infinite loop in REPL in 1.12?

**URL:** <https://discourse.julialang.org/t/how-do-i-break-out-of-an-infinite-loop-in-repl-in-1-12/127691>\
**Category:** General Usage\
**Created:** [April 3, 2025, 11:48pm UTC](https://discourse.julialang.org/t/how-do-i-break-out-of-an-infinite-loop-in-repl-in-1-12/127691 "2025-04-03T23:48:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![R.T.A.M](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/r.t.a.m/32/22289_2.png) [@R.T.A.M](https://discourse.julialang.org/u/R.T.A.M)\
**Post date:** [April 3, 2025, 11:48pm UTC](https://discourse.julialang.org/t/how-do-i-break-out-of-an-infinite-loop-in-repl-in-1-12/127691/1 "2025-04-03T23:48:05Z")

</div>

While testing the new 1.12 features I tried the following in a REPL:

```julia

f(x) = while x end
f(true)

```

The infinite loop works, so is there a way to break out of it in the REPL using CTRL+ D? Now that there are interactive and worker threads, how is the break command handled?

---

<div class="post-metadata">

**Author:** ![ForceBru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forcebru/32/21389_2.png) [@ForceBru](https://discourse.julialang.org/u/ForceBru)\
**Post date:** [April 3, 2025, 11:57pm UTC](https://discourse.julialang.org/t/how-do-i-break-out-of-an-infinite-loop-in-repl-in-1-12/127691/2 "2025-04-03T23:57:34Z")

</div>

Does CTRL+C not work?

---

<div class="post-metadata">

**Author:** ![R.T.A.M](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/r.t.a.m/32/22289_2.png) [@R.T.A.M](https://discourse.julialang.org/u/R.T.A.M)\
**Post date:** [April 4, 2025, 12:05am UTC](https://discourse.julialang.org/t/how-do-i-break-out-of-an-infinite-loop-in-repl-in-1-12/127691/3 "2025-04-04T00:05:14Z")

</div>

Nope. Tried the whole control alphabet.

But that little ‘x’ in the corner works 😉

---

<div class="post-metadata">

**Author:** ![R.T.A.M](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/r.t.a.m/32/22289_2.png) [@R.T.A.M](https://discourse.julialang.org/u/R.T.A.M)\
**Post date:** [April 4, 2025, 12:19am UTC](https://discourse.julialang.org/t/how-do-i-break-out-of-an-infinite-loop-in-repl-in-1-12/127691/4 "2025-04-04T00:19:53Z")

</div>

Also, if

```julia
Threads.@spawn f(true)

```

Ctrl-D cant do its thing either.  
This in a windows laptop.

On a Linux machine Ctrl-Z stops Julia and drops back to the shell.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [April 4, 2025, 2:14am UTC](https://discourse.julialang.org/t/how-do-i-break-out-of-an-infinite-loop-in-repl-in-1-12/127691/5 "2025-04-04T02:14:39Z")

</div>

IIRC the keyboard interrupt (always been Ctrl+C for me on Windows) needs something to work gracefully on Windows. Yielding to the task scheduler (which many functions like `sleep` do) is one thing, but it’s not everything. For me, spamming Ctrl+C does eventually force a SIGINT and interrupt.

```julia
julia> while true sleep(1) end # Ctrl+C works first try
ERROR: InterruptException:
...

julia> while true Libc.systemsleep(1) end # non-yielding sleep, need spamming
WARNING: Force throwing a SIGINT
ERROR: InterruptException:
...

julia> while true end
WARNING: Force throwing a SIGINT
ERROR: InterruptException:
...

```

But this is on v1.11.4, haven’t tried 1.12.
