Changeset 5544
- Timestamp:
- 06/27/08 15:51:36 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
framework3/trunk/lib/msf/ui/console/command_dispatcher/core.rb
r5536 r5544 737 737 738 738 session.interact(driver.input.dup, driver.output) 739 739 740 740 self.active_session = nil 741 741 … … 757 757 rescue IOError, EOFError, Rex::StreamClosedError 758 758 print_status("Session stream closed.") 759 rescue 759 rescue ::Interrupt 760 raise $! 761 rescue ::Exception 760 762 log_error("Session manipulation failed: #{$!} #{$!.backtrace.inspect}") 761 763 end framework3/trunk/lib/rex/ui/text/input/readline.rb
r5543 r5544 38 38 def child_readline(wtr, prompt, history) 39 39 $0 = "<readline>" 40 40 41 line = ::Readline.readline(prompt, history) 41 42 line = "\n" if (line and line.strip.length == 0) 43 42 44 wtr.write(line || "exit\n") 43 45 wtr.flush 44 46 wtr.close 45 exit(0) 47 48 # Self-destruct mechanism activated 49 Process.kill(9, $$) 46 50 end 47 51 … … 58 62 def sysread(len = 1) 59 63 $stdin.sysread(len) 60 61 64 end 62 65 … … 76 79 def pgets 77 80 78 # if(Rex::Compat.is_windows()) 79 if(true) 81 if(Rex::Compat.is_windows()) 80 82 output.prompting 81 83 line = ::Readline.readline(prompt, true) … … 84 86 end 85 87 86 # Wrap readline in a child process and secure with a mutex 87 # This prevents threading hangs in the calling process. 88 require "thread" 89 @@child_mutex ||= Mutex.new 90 @@child_mutex.synchronize do 88 89 line = "" 91 90 92 91 output.prompting … … 112 111 ::Process.waitpid(pid, 0) 113 112 113 # Parse the results 114 114 if line 115 115 HISTORY.push(line) if (not line.empty?) … … 118 118 eof = true 119 119 return line 120 end 121 122 # Release the readline mutex 123 end 120 end 121 124 122 end 125 123
