gulden has asked for the wisdom of the Perl Monks concerning the following question:
#!/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:
Any tips?$ perl -Mthreads -e 'print $threads::VERSION' 1.71 $ perl -v This is perl, v5.8.8 built for sun4-solaris-thread-multi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Threads + opendir = Segmentation Fault (core dumped)
by BrowserUk (Patriarch) on Jun 24, 2009 at 17:01 UTC | |
by lightoverhead (Pilgrim) on Jun 24, 2009 at 19:23 UTC | |
by BrowserUk (Patriarch) on Jun 24, 2009 at 19:36 UTC | |
by gulden (Monk) on Jun 24, 2009 at 17:18 UTC | |
|
Re: Threads + opendir = Segmentation Fault (core dumped)
by jwkrahn (Abbot) on Jun 24, 2009 at 17:32 UTC |