So, I started playing around with threads, using Re: buffering zipped pipes as an example. I got something working on my Windows machine, then tried it out on the ancient linux box (perl 5.8.5)... and got the dreaded "A thread exited while 2 threads were running."

I double-checked to make sure that the linux box's perldoc threads claimed support for ->detach, and the WARNINGS section suggested joining to remove the error. I thought ->detach was supposed to make it automatically clean up such stuff.

I tried no warnings 'threads'; or even no warnings;, just to see if I could make the warning go away, but it stuck around.

Given the details (below), how can I get around this warning? Can I install a new local version of threads on the linux machine (I have cpan set up for local library installs), or is threads too core to be able to update with cpan? Or should I just switch to not using ->detach, and do manual cleanup using ->join?

tl;dr details follow...

windows

C:> perl -v | head -2 | tail -1 This is perl 5, version 24, subversion 0 (v5.24.0) built for MSWin32-x +64-multi-thread C:> perl -V | egrep "thread.*=" useithreads=define, usemultiplicity=define C:> perl -Mthreads -le "print $threads::VERSION;" 2.07 C:> perl -Mthreads -le "async { sleep 100; } ; exit;" Perl exited with active threads: 1 running and unjoined 0 finished and unjoined 0 running and detached C:> perl -Mthreads -le "async { sleep 100; }->detach ; exit;" C:>

linux

$ perl -v | head -2 | tail -1 This is perl, v5.8.5 built for i386-linux-thread-multi $ perl -V | egrep 'thread.*=' config_args='-des -Doptimize=-O2 -g -pipe -m32 -march=i386 -mtune= +pentium4 -Dversion=5.8.5 -Dmyhostname=localhost -Dperladmin=root@loca +lhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/u +sr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Duses +hrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semc +tl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm + -Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpage +r=/usr/bin/less -isr -Dinc_version_list=5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 +' usethreads=define use5005threads=undef useithreads=define usemulti +plicity=define $ perl -Mthreads -le 'print $threads::VERSION;' 1.05 $ perl -Mthreads -le 'async { sleep 100; } ; exit;' A thread exited while 2 threads were running. $ perl -Mthreads -le 'async { sleep 100; }->detach ; exit;' A thread exited while 2 threads were running. $ perl -Mthreads -le 'no warnings; async { sleep 100; }->detach ; exit +;' A thread exited while 2 threads were running. $

In reply to detached threads still warn by pryrt

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.