jonathanstowe / TermReadKey

Character mode terminal access for Perl
12 stars 27 forks source link

ReadKey -1 is blocking (ActiveState/Windows7) #28

Closed Theemim closed 5 years ago

Theemim commented 7 years ago

On this system:

I am seeing ReadKey(-1) block until a key is pressed. Ideas? Thank you.

use strict;
use warnings;
use Term::ReadKey;

$|=1;
print("\nStarting ReadKey blocking test.  Do not hit a key...\n");
testReadKey(1);   # ReadKey times out and returns undef as expected
testReadKey(-1);  # ReadKey blocks until a key is pressed
print("\nTest complete\n");

sub testReadKey {
  my $readKeyArg = shift;
  print("\nTesting \$key=ReadKey($readKeyArg) : ");
  ReadMode(4);
  my $key = ReadKey($readKeyArg);
  ReadMode(0);
  if(not defined $key) {
    print("\$key is undefined, test passed\n");
  }
  else {
    print("\$key is defined, test failed\n");
  }
}
amba commented 7 years ago

Hey Theemim, This might be related to recent issue #25. The fix for this is not yet on CPAN. In our case the workaround is to use the older 2.30 CPAN release.

jonathanstowe commented 5 years ago

I'm going to close this now as I am unable to reproduce. Please re-open with a PR if this is still problem.