in reply to Re: detached threads still warn
in thread detached threads still warn

I was hoping I could do something like installing a local version of threads.pm to distribute with my script... alas.

Unfortunately, "upgrade perl" is not an option on that family of boxes (they were configured a decade ago for a particular purpose to work in a particular proprietary situation), and any tool I develop for those boxes must work within that framework. If threads ends up improving on my existing script (I don't even know if they will), I'll do a shell wrapper to grep -v that warning away. (My fellow users would complain every time they get a warning using my script.)

Thanks hippo and BrowserUK... at least I know I'm not just doing something wrong.

Replies are listed 'Best First'.
Re^3: detached threads still warn
by stevieb (Canon) on Oct 07, 2016 at 17:38 UTC

    If the warning is meaningless as others have stated, you can catch all warnings by specifying a $SIG{__WARN__} handler, and prevent printing of that specific one:

    use warnings; use strict; $SIG{__WARN__} = sub { my $warn = shift; if ($warn !~ /^A thread exited/){ print $warn; } }; warn "blah blah warning\n"; warn "A thread exited...\n";

    Output:

    blah blah warning

    update: I just realized that the signal handler for warn does not appear to be re-entrant for a warn call from within the handler itself... that is, you can replace my print statement inside the handler with warn, and re-throw the actual warning:

    perl -E '$SIG{__WARN__}=sub{say "handler";warn $_[0] if $_[0]!~/^A thr +ead/}; warn "blah"; warn "A thread";' handler blah at -e line 1. handler

    /update