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


In reply to I am not able to join a thread when another child process is running which was forked using open. by ashishyadavlko1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.