I'm getting a "Segmentation Fault (core dumped) ", caused by "opendir" function, when running the folowing code:
#!/opt/coolstack/bin/perl use strict; use threads ('yield', 'stack_size' => 64*4096, 'exit' => 'threads_only', 'stringify'); #--------------------------------------------------------------- my $path = "/tmp"; my $time = time; #my @files = qw(detail-1min-19-06-22); my @files = &get_files($path); my @thrs_loaders; foreach my $file (@files){ my ($thr) = threads->create(\&load, $file); push @thrs_loaders, $thr; } $_->join for @thrs_loaders; exit; #--------------------------------------------------------------------- sub get_files{ my $dir = shift; opendir(DIR, $dir) or die "Cant open dir $!"; # HERE IS THE CAUSE close(DIR); return "detail-1min-19-06-22"; } #--------------------------------------------------------------------- sub load{ my $file = shift; print "Processing $file\n"; }

I've tested in:

$ perl -Mthreads -e 'print $threads::VERSION' 1.71 $ perl -v This is perl, v5.8.8 built for sun4-solaris-thread-multi
Any tips?

In reply to Threads + opendir = Segmentation Fault (core dumped) by gulden

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.