I’m using: SWI-Prolog version 8.1.17
I want the code to: I’m running a long running program using the swi-mqtt-pack library that is apparently starting up additional threads for callbacks. There are times when I’m getting a MQTT disconnect message from the MQTT broker and in the callback I’ve set up for that message I want my code to just exit (it runs in a Docker container and will be restarted).
I am currently trying to exit the program with:
thread_send_message(main, quit).
But sometimes I’ll get a message like:
% The following threads wouldn’t die: [(3,0x16ef3d0)]
So it appears that I’d have to go through each of the threads the program might have started and kill them one by one, but I don’t know how to do this. Since I’m doing this from within a callback it could very well be a subthread that I’m doing this from. The “main” of my code is like:
main :-
setup_signals,
start_servers(swi_mqtt_brain),
wait.
where the start_servers starts up the mqtt connection and registers a callback on_disconnect. It’s in the predicate called by the on_disconnect callback that I want to shut down everything, quit, and let my container be restarted by Docker.