in reply to Threads + opendir = Segmentation Fault (core dumped)
Try this
#! perl use strict; use threads ( 'yield', 'stack_size' => 64*4096, 'exit' => 'threads_only', 'stringify' ); my $path = "/tmp"; my @files = &get_files($path); my @thrs_loaders; foreach my $file (@files){ push @thrs_loaders, threads->create(\&load, $file); } $_->join for @thrs_loaders; <>; exit; sub get_files{ my $dir = shift; opendir(my $dh, $dir) or die "Cant open dir $!"; # HERE IS THE CAUS +E close( $dh); return "detail-1min-19-06-22"; } sub load{ my $file = shift; print "Processing $file\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Threads + opendir = Segmentation Fault (core dumped)
by lightoverhead (Pilgrim) on Jun 24, 2009 at 19:23 UTC | |
by BrowserUk (Patriarch) on Jun 24, 2009 at 19:36 UTC | |
|
Re^2: Threads + opendir = Segmentation Fault (core dumped)
by gulden (Monk) on Jun 24, 2009 at 17:18 UTC |