[tpm] Control-D blocks STDIN when another thread is running
Viktor Pavlenko
vvp at cogeco.ca
Mon May 13 13:39:33 PDT 2013
Hello All!
I have a multithreaded perl script where the main thread runs an
interactive loop getting user input and passes it for processing to
another thread. All works fine except when I press Control-D at the
prompt. There's no response and I have to use ^\ to kill the script.
The problem can be reproduced with the following script:
bash-3.2$ cat ./stdin_test.pl
#!/usr/bin/perl -w
use strict;
use threads;
my $t = threads->create(sub { sleep 10; print "done\n" });
while (<>) {
print $_;
}
$t->join();
print "bye\n";
bash-3.2$ ./stdin_test.pl
aa
aa
<------------- hitting ^d here, blocks until another thread exits
done
bye
bash-3.2$
I'm on linux, tried both perl versions 5.8.8 and 5.10.1. Google search
strangely gave me nothing.
--
Viktor
More information about the toronto-pm
mailing list