linux - Term::Readline unusual behavior -


i creating shell prompt using term::readline given below -

my $expire_time = time + 25; # 25 sec timeout testing , shared thread $prompt   = 'shell> '; $terminal = term::readline->new('shell interface'); $attribs  = $terminal->attribs; $terminal->ornaments(0);    # disable ornaments.  while ( defined( $_ = $terminal->readline($prompt) ) ) {     if (/^\s*quit\s*$/xms) {         # cleanup global parameters         #...some cleanup code          # signal thread terminate, , detach         # cleaned automatically         # using thread control customize shell         $thread->kill('kill')->detach();         last;         }  }   $thread = threads->create(         sub {             local $sig{kill} = sub { threads->exit() };             eval {                 $buffer_interval = int( sqrt( $expire_time - time() ) );                 $term            = term::readline->new('handle session of shell');                 $term->ornaments(0);                  $message = "do want extend session?[y/n]- ";               inner: while ( $expire_time > time() ) {                      $diff = $expire_time - time();                     sleep 1;                      print "diff - $diff, buffer_interval - $buffer_interval\n";                      if ( $diff == $buffer_interval ) {                          "your session expire in $diff seconds due inactivity.";                         while ( defined( $_ = $term->readline($message) ) )                         {                             if (/^y$/i) {                                 $expire_time += $timeout;                                 "refreshed expire_time - $expire_time";                             }                             next inner;                         }                     }                 }                 &killproc('shell')                   or die "cannot kill shell, aborting";             };         }     ); 

this thread handle timeout of shell, $expire_time set value 90 seconds, square root of timeout means 9 sec before user warning message session expire soon.. , if user enter 'y' session extended $expire_time.

but when term::readline object created in thread , not behaving in right way, sometime on entering 'y' session extend , sometime not.

example given below -

expire time - 1430279631
shell> diff - 25, buffer_interval - 5
diff - 24, buffer_interval - 5
diff - 23, buffer_interval - 5
diff - 22, buffer_interval - 5
diff - 21, buffer_interval - 5
diff - 20, buffer_interval - 5
diff - 19, buffer_interval - 5
diff - 18, buffer_interval - 5
diff - 17, buffer_interval - 5
diff - 16, buffer_interval - 5
diff - 15, buffer_interval - 5
diff - 14, buffer_interval - 5
diff - 13, buffer_interval - 5
diff - 12, buffer_interval - 5
diff - 11, buffer_interval - 5
diff - 10, buffer_interval - 5
diff - 9, buffer_interval - 5
diff - 8, buffer_interval - 5
diff - 7, buffer_interval - 5
diff - 6, buffer_interval - 5
diff - 5, buffer_interval - 5
session expire in 5 seconds due inactivity.
want extend session?[y/n]- y
shell>

it not printing message inside while() loop saying refreshing expire time...

is problem because in term::readline prompt , again using term::readline prompt inside one?

is there flushing problem?


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -