<div dir="ltr">When you press ^D, whether before or after the thread has printed "done", the main process exits the loop, and goes on to the join. If necessary, it waits for the thread to terminate and the join() to be performed. <div>
<br></div><div style>How would you like it to be different? I suppose you could detect a special input, and exit at that point.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 13, 2013 at 4:39 PM, Viktor Pavlenko <span dir="ltr"><<a href="mailto:vvp@cogeco.ca" target="_blank">vvp@cogeco.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello All!<br>
<br>
I have a multithreaded perl script where the main thread runs an<br>
interactive loop getting user input and passes it for processing to<br>
another thread. All works fine except when I press Control-D at the<br>
prompt. There's no response and I have to use ^\ to kill the script.<br>
<br>
The problem can be reproduced with the following script:<br>
<br>
bash-3.2$ cat ./<a href="http://stdin_test.pl" target="_blank">stdin_test.pl</a><br>
#!/usr/bin/perl -w<br>
<br>
use strict;<br>
use threads;<br>
<br>
my $t = threads->create(sub { sleep 10; print "done\n" });<br>
<br>
while (<>) {<br>
      print $_;<br>
}<br>
<br>
$t->join();<br>
print "bye\n";<br>
<br>
bash-3.2$ ./<a href="http://stdin_test.pl" target="_blank">stdin_test.pl</a><br>
aa<br>
aa<br>
<------------- hitting ^d here, blocks until another thread exits<br>
done<br>
bye<br>
bash-3.2$<br>
<br>
I'm on linux, tried both perl versions 5.8.8 and 5.10.1. Google search<br>
strangely gave me nothing.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Viktor<br>
_______________________________________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br>
</font></span></blockquote></div><br></div>