# Ctrl-c (sigint) not working systematically (on osx)

**URL:** <https://swi-prolog.discourse.group/t/ctrl-c-sigint-not-working-systematically-on-osx/2390>\
**Category:** Tools\
**Created:** [May 21, 2020, 8:41pm UTC](https://swi-prolog.discourse.group/t/ctrl-c-sigint-not-working-systematically-on-osx/2390 "2020-05-21T20:41:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grsjst](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grsjst/32/930_2.png) [@grsjst](https://swi-prolog.discourse.group/u/grsjst)\
**Post date:** [May 21, 2020, 8:41pm UTC](https://swi-prolog.discourse.group/t/ctrl-c-sigint-not-working-systematically-on-osx/2390/1 "2020-05-21T20:41:45Z")

</div>

hello,

Since a while (not sure how long), pressing “ctrl-c” in a terminal window no longer systematically interrupts the running query for me. It notably seems to happen with a bogus DCG grammar that gets into an infinite loop, but I am not entirely sure this is causing it. Some queries (e.g. between/3) do react correctly to a ctrl-c interrupt.

Does anyone else experience this behaviour, or has ideas where this might be coming from?

I am running:

```nohighlight
Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.32-10-g1885b056f)
Darwin scissors 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64

```

thanks for any suggestions you may have

Joost

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [May 22, 2020, 6:59am UTC](https://swi-prolog.discourse.group/t/ctrl-c-sigint-not-working-systematically-on-osx/2390/2 "2020-05-22T06:59:33Z")

</div>

What really matters typically is libedit/readline/no command line editing, embedding (swipl-win), Emacs, PDT, … and probably the OS. Interrupt handling in Prolog itself hasn’t been changed for a long time and also the interrupt handling in the commandline editors hasn’t changed for some time. Surely libedit in a Linux terminal works fine …

---

<div class="post-metadata">

**Author:** ![esad](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/esad/32/884_2.png) [@esad](https://swi-prolog.discourse.group/u/esad)\
**Post date:** [May 23, 2020, 2:22pm UTC](https://swi-prolog.discourse.group/t/ctrl-c-sigint-not-working-systematically-on-osx/2390/3 "2020-05-23T14:22:55Z")

</div>

I thought I had the same issue, then I realized that the unresponsive code was a `http_open` in the setup part of `setup_call_cleanup/3`. From the docs: _“The execution of Setup is protected from asynchronous interrupts like call\_with\_time\_limit/2 (package clib) or thread\_signal/2”_. So when a remote host would be unresponsive, I couldn’t terminate the request from top level via Ctrl-C.

I’ve seen this pattern of putting http\_open in the setup a lot in other sources and picked it up (as someone wise said, _“Copy-pasting code from the StackOverflow into production code is like chewing gum found on the street”_ 🙂
