Files
scryer-prolog/tests-pl/issue-interrupt-nontermination.pl
Danil Platonov 39c850b4f4 Test that SIGINT interrupts non-terminating goals on unix.
Cleanup: use tokio::test instead of special test helpers

Added pty_exec.py helper script to run binaries with a pseudoterminal attached (bug won't trigger otherwise).

Tested CI to fail on all unixes (ubuntu+macos) with older rustyline, and pass with new one.
2026-05-30 11:45:57 -07:00

38 lines
1.0 KiB
Prolog

% Server
:- use_module(library(process)).
:- use_module(library(charsio)).
:- use_module(library(lists)).
:- use_module(library(time)).
prolog_path(Prolog) :-
read(Body),
term_variables(Body, [Prolog]),
Body.
main :-
prolog_path(Prolog),
CMD = "\
use_module(library(os)), \
pid(PID), \
write(PID), nl, \
asserta((f :- f)), \
catch(f, Err, (write(Err),nl)), \
write(done), nl, \
halt.",
process_create("tests-pl/pty_exec.py", [Prolog, "-g", CMD], [stdout(pipe(O))]),
get_line_to_chars(O, PID0, ""),
append(PID, "\r\n", PID0),
process_create("kill", ["-s", "INT", PID], []),
sleep(5),
% second kill should fail because process should exit after one kill
process_create("kill", ["-s", "INT", PID], [stderr(null), process(PK)]),
process_wait(PK, Status),
status_report(Status, PID), nl.
status_report(exit(1), _PID) :- write(ok).
status_report(exit(0), PID) :-
write(not_dead),
% kill by force to exit cleanly
process_create("kill", ["-9", PID], []).
:- initialization(main).