Changeset 5541

Show
Ignore:
Timestamp:
06/27/08 14:57:28 (4 months ago)
Author:
hdm
Message:

Correctly handle the readline threading issue, tested with sessions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/lib/rex/ui/text/input/readline.rb

    r5539 r5541  
    1616        class Input::Readline < Rex::Ui::Text::Input 
    1717                include ::Readline 
    18  
     18                 
    1919                # 
    2020                # Initializes the readline-aware Input instance for text. 
     
    7575                # 
    7676                def pgets 
    77                         
    78                         if(true
     77                 
     78                        if(Rex::Compat.is_windows()
    7979                                output.prompting 
    8080                                line = ::Readline.readline(prompt, true) 
     
    8282                                return line 
    8383                        end 
    84                          
     84 
     85                        # Wrap readline in a child process and secure with a mutex 
     86                        # This prevents threading hangs in the calling process. 
     87                        require "thread" 
     88                        @@child_mutex ||= Mutex.new 
     89                        @@child_mutex.synchronize do 
    8590                         
    8691                        output.prompting 
     
    112117                                eof = true 
    113118                                return line 
     119                        end 
     120                         
     121                        # Release the readline mutex 
    114122                        end 
    115123                end