lib/ttytest/tmux/session.rb in ttytest2-0.9.10 vs lib/ttytest/tmux/session.rb in ttytest2-0.9.11

- old
+ new

@@ -4,19 +4,20 @@ module Tmux # represents a tmux session and how to send output to the current tmux session class Session # @api private def initialize(driver, name) + @id = SecureRandom.uuid @driver = driver @name = name - # ObjectSpace.define_finalizer(self, self.class.finalize(driver, name)) + ObjectSpace.define_finalizer(@id, proc { + begin + driver.tmux(*%W[kill-session -t #{name}]) + rescue ThreadError => _e # final session always throws, ThreadError can't alloc new + end + }) end - - # @api private - # def self.finalize(driver, name) - # proc { driver.tmux(*%W[kill-session -t #{name}]) } - # end def capture contents = driver.tmux(*%W[capture-pane -t #{name} -p]) str = driver.tmux(*%W[display-message -t #{name} -p #\{cursor_x},#\{cursor_y},#\{cursor_flag},#\{pane_width},#\{pane_height},#\{pane_dead},#\{pane_dead_status},])