Where does the toplevel go?

Consider this code to be run from the interactive toplevel:

go :-
  thread_create(console, T),
  thread_join(T, Status),
  writeln(status:Status), !.

console :-
	with_tty_raw(get_single_char(C)),
	writeln(get_single_char(C)).

When I run it I get output I expect …

?- go.
get_single_char(103)
status:true
true.

but the interactive toplevel ?- prompt doesn’t come back.

What’s happening? And what have I missed in the documentation that would have prepared me to expect this?

I see the new thread would “inherit” prompt, user_input, user_output but it’s not clear that the original thread wouldn’t resume as usual once the new thread terminates.

The stream lock was not released. Pushed a fix.

2 Likes