I just had an afterthought I how you may experiment to force killing your detached threads.
Use a shared variable $die and in your loop have return if $die. I'm not sure where to put it exactly in your code, but it would be a way to force breaking out of the while (<$out>) loop. It will force all detached threads to return. If it works for you, you can setup a shared hash, with a $shash{$thread_num}{'die'} for each thread, so you can control which threads get the $die=1 and return. You may also add a sub to perform in the thread when the die is received, like possibly closing the $out filehandle before returning.
This is why I don't use Queue or any of the other thread conveyer belt modules, they separate you from full control.
use threads::shared;
my $die : shared; #declare as shared before setting value
$die = 0;
while (<$out>) {
return if $die;
chomp;
$err = 1 if (/^thread failed/);
$Q->enqueue("$tid:$uut:$test:$_");
last if ($err);
}
while (1) {
.......
........
# put $die at an appropriate spot
$die =1;
......
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.