Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > issue with multiprocess - fork

Reply
Thread Tools

issue with multiprocess - fork

 
 
friend.05@gmail.com
Guest
Posts: n/a
 
      08-06-2009
My script is using fork so there are child processes. Sometimes my
script runs properly and output is correct. But sometime my script
gets stuck just after exiting child process.

Below is psudo code. (not sure if this helps, it is juist snap shot)

foreach my $w (keys %worklist) {
my $child;
unless ($child = fork()) {
die("connot for: $!") unless defined $child;

foreach my $file (@{$worklist{$w}}) {
#reading files processing of data and
creating hash tables.
}

#ouput files from hash tables. outfile files will be
for each child.

print "Worker $w $$ exiting\n";
#child
exiting
(#it gets stuck after printing this statement)

exit;
}
push(@workers, $child); #array of child PID

}

#wating for each child to finish.
foreach my $pid (@workers) {
$s = waitpid($pid, 0);
print "$s finished\n";

}


The freeze happens sometimes.

And I check the trace(truss -p on sun). I found that sometimes one of
the child goes to sleeping and parent is still waiting for that child
exit status. But it never gets that bcoz child is sleeping.

And suggestion what can be problem or else how can I debug more.

Thanks
 
Reply With Quote
 
 
 
 
Xho Jingleheimerschmidt
Guest
Posts: n/a
 
      08-07-2009
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> My script is using fork so there are child processes. Sometimes my
> script runs properly and output is correct. But sometime my script
> gets stuck just after exiting child process.


Asking the same question under a different subject line is more likely
to annoy the people you want to help you, than it is to get you more help.

Threads exist for a reason.

Xho
 
Reply With Quote
 
 
 
 
friend.05@gmail.com
Guest
Posts: n/a
 
      08-07-2009
On Aug 7, 8:29*am, Tad J McClellan <(E-Mail Removed)> wrote:
> Xho Jingleheimerschmidt <(E-Mail Removed)> wrote:
> > (E-Mail Removed) wrote:
> >> My script is using fork so there are child processes. Sometimes my
> >> script runs properly and output is correct. But sometime my script
> >> gets stuck just after exiting child process.

>
> > Asking the same question under a different subject line is more likely
> > to annoy the people you want to help you, than it is to get you more help.

>
> Indeed, as I had killfiled this OP in April when he crossposted
> the first time.
>
> * *http://groups.google.com/groups/sear...F119t50U2%40mi...
>
> I thought at the time that it was perhaps a bit harsh to banish
> him to perpetual invisibility, but I did it anyway.
>
> Seeing that he still does it after being warned about it makes
> me feel better about my original decision.
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


sorry about that. I thought it 3days so people might not see the
thread and I am stuck at that problem. so I posted new thread.

will be careful next time
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Permission denied and lock issue with multiprocess logging david dani Python 1 06-12-2011 08:18 PM
Permission dened and lock runtime error with multiprocess logging davidani Python 0 06-11-2011 01:56 PM
Multithreading / multiprocess tleeuwenburg@gmail.com Python 4 04-12-2009 11:27 AM
Dprof in a multiprocess script flazan Perl Misc 0 05-04-2004 10:28 AM
stream in multiprocess (multithread) apps Michael Shestero C++ 4 12-19-2003 04:33 PM



Advertisments