swipl-devel
swipl-devel copied to clipboard
"Interrupted system call" error when sending EOF (^D) immediately after entering break level
I'm using SWI-Prolog 8.3.16 built from source (d307e9469107059e69fa9bb4e404d0ed78d0a0fd) on macOS 10.14.6. I can reproducibly cause an "Interrupted system call" I/O error using these steps:
- Start SWI-Prolog interactively
- While at the
?-
prompt, send an interrupt (^C) - Enter a break level (b)
- Immediately send an EOF (^D)
This shows an error once, but sending ^D a second time works and exits the break level as expected. If I run a query in the break level first, ^D also works right away without errors.
Full output and error backtrace
$ src/swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.16-33-gd307e9469)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
CMake built from "<builddir>"
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- ^C
Action (h for help) ? break
% Break level 1
[1] ?- ERROR: '$raw_read'/2: I/O error in read on stream user_input (Interrupted system call)
ERROR: I/O error in read on stream user_input (Interrupted system call)
ERROR: In:
ERROR: [15] throw(error(io_error(read,user_input),context(...,'Interrupted system call')))
ERROR: [13] read_query('[1] ~! ?- ',_21348,_21350) at <builddir>/home/boot/toplevel.pl:872
ERROR: [12] read_expanded_query(1,_21376,_21378) at <builddir>/home/boot/toplevel.pl:841
ERROR: [11] '$query_loop' at <builddir>/home/boot/toplevel.pl:813
ERROR: [10] <meta call>
ERROR: [9] '$raw_read'(user_input,_21448) <foreign>
ERROR: [8] read_term_as_atom(user_input,_21474) at <builddir>/home/boot/toplevel.pl:905
ERROR: [7] catch('$toplevel':read_term_as_atom(user_input,_21514),_21500,'$toplevel':true) at <builddir>/home/boot/init.pl:535
ERROR: [6] read_query_line(user_input,_21546) at <builddir>/home/boot/toplevel.pl:888
ERROR: [5] read_query('~! ?- ',_21572,_21574) at <builddir>/home/boot/toplevel.pl:872
ERROR: [4] read_expanded_query(0,_21600,_21602) at <builddir>/home/boot/toplevel.pl:841
ERROR: [3] '$query_loop' at <builddir>/home/boot/toplevel.pl:813
ERROR: [2] '$runtoplevel' at <builddir>/home/boot/toplevel.pl:715
ERROR: [1] '$toplevel' at <builddir>/home/boot/toplevel.pl:701
ERROR: [0] <meta call>
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
[1] ?- ^D
% Exit break level 1
Action (h for help) ? abort
% Execution Aborted
?-
Thanks. Reproduces on Linux, and I guess on any system where we use libedit for command line editing. Seems something with packages/libedit/libedit4pl.c, read_char(). I thought clearing the error before PL_handle_signals() call might fix it, but that doesn't help.
Doesn't seem important enough to spend a lot of time on. Of course, if you can't resist ...