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


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:

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


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 …

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” :slight_smile:

1 Like