Commit d088f0c

mo khan <mo@mokhan.ca>
2026-09-07 23:45:37
stop the dots thread with a cooperative flag plus join instead of Thread#kill
Thread#kill can terminate mid-write, corrupting output. Port of a fix made against the old core Terminal before it was extracted here.
1 parent b8bc117
Changed files (1)
lib
elelem
builtins
lib/elelem/builtins/terminal.rb
@@ -38,7 +38,7 @@ module Elelem
       def waiting
         stop_dots
         @dots_thread = Thread.new do
-          loop do
+          until Thread.current[:stop]
             @stream.print "."
             @stream.flush
             sleep 0.1
@@ -76,7 +76,8 @@ module Elelem
       def stop_dots
         return unless @dots_thread
 
-        @dots_thread.kill
+        @dots_thread[:stop] = true
+        @dots_thread.join
         @dots_thread = nil
         write("\n")
         @at_line_start = true