I am using threads module to execute 10 threads a a time. They are actually doing a curl to download a file (all 10 of them). Now, some times the curl fails and it returns an error code. This error code I want to capture and report. I cannot find how Threads returns me return/exit codes of a thread. Here is my code snippet:
my $count = 10; my @threads = (); for (1..$count) { my $tid = threads->new(\&RunChild, $_); push (@threads, $tid); } foreach (@threads) { my $num = $_->join(); #Here I want to check return code of thread, so that I can report the +error. my $error = ????; if ($error) { print "Thread $num returned error $error\n"; } else { print "Thread $num completed\n"; } } sub RunChild { my $callNum = $_[0]; `curl -o $callNum "http://192.168.1.23/abc.flv"` return $callNum; }

In reply to Thread Exit Status by anshumangoyal

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.