# usage: # ruby -I lib -r session test/threadtest.rb # SESSION_USE_SPAWN=1 ruby -I lib -r session test/threadtest.rb require 'session' $VERBOSE=nil STDOUT.sync = true STDERR.sync = true STDOUT.puts "Session::VERSION <#{ Session::VERSION }>" STDOUT.puts "Session.use_spawn <#{ Session.use_spawn ? 'true' : 'false' }>" STDOUT.puts "the following timestamps should come back about 1 second apart or there are problems..." thread = Thread.new { cmd = 'date; sleep 1;' * 3 sh = Session.new #:use_spawn=>true sh.execute(cmd) do |o,e| line = o || e p [Time.now.to_f, line] end }.join