lib/expectr.rb in expectr-1.0.2 vs lib/expectr.rb in expectr-1.0.3

- old
+ new

@@ -1,10 +1,11 @@ require 'pty' require 'timeout' require 'thread' require 'expectr/error' +require 'expectr/version' # Public: Expectr is an API to the functionality of Expect (see # http://expect.nist.gov) implemented in ruby. # # Expectr contrasts with Ruby's built-in Expect class by avoiding tying in @@ -140,24 +141,30 @@ # Save our old tty settings and set up our new environment old_tty = `stty -g` `stty -icanon min 1 time 0 -echo` - # SIGINT should be set along to the program - oldtrap = trap 'INT' do + # SIGINT should be sent along to the process. + old_int_trap = trap 'INT' do send "\C-c" end + + # SIGTSTP should be sent along to the process as well. + old_tstp_trap = trap 'TSTP' do + send "\C-z" + end interact = Thread.new do input = ''.encode("UTF-8") while @pid > 0 && @interact if select([STDIN], nil, nil, 1) c = STDIN.getc.chr send c unless c.nil? end end - trap 'INT', oldtrap + trap 'INT', old_int_trap + trap 'TSTP', old_tstp_trap `stty #{old_tty}` @interact = false end blocking ? interact.join : interact