I want to do following things from main thread/process:
1. Communicate to another process using pipe.
2. Create threads to do certain task.
3. Wait for all the threads to complete.
Following is the pseudo code I am trying:
use threads;
use IO::Handle;
sub dummy {
print "\n!!!!". $$;
return 0;
}
open($handle, "| cat -v") || die "Unable to open connection to BT Dri
+ver: $!\n";
$handle->autoflush(1);
#close $handle; If I uncomment this, threads can be joined. But I don
+'t want to terminate this child process.
$thr2 = threads->create(\&dummy);
sleep 2;
print "\n$thr2";
foreach $thr (threads->list(threads::joinable))
{
print "\nIam here";
print "\n!!!". $thr;
$thr->join();
}
Code gets stuck when I try to join the thread even though it is joinable.
Am I doing something fundamentally wrong here? I am using Perl 5.10.0