in reply to Re^3: Segmentation fault: problem with perl threads
in thread Segmentation fault: problem with perl threads

hi,

Could you please direct me to read through forked way of doing parallel processing?

Thanks,

katharnakh.

  • Comment on Re^4: Segmentation fault: problem with perl threads

Replies are listed 'Best First'.
Re^5: Segmentation fault: problem with perl threads
by zentara (Cardinal) on Sep 15, 2008 at 15:52 UTC
    All you do is drop your thread code block into a forked child's code block. Not recomended, but the simplest is:
    if(fork() == 0){exec("command")}
    but that dosn't watch for zombies, or limit the number of forks at any one time.

    Usually, you do something like:

    #!/usr/bin/perl # There is a limit to the number of child processes you can # have, or should want, so big jobs may require the kind of # throttling Parallel::ForkManager gives you. #The receipe for 100 processes: #avoid zombies $SIG{CHLD} = 'IGNORE'; # check if it works on your system for (1..100) { my $pid = fork; next if $pid; # in parent, go on warn($!), next if not defined $pid; # parent, fork errored out exec @cmd; # in child, # go do @cmd and don't come back }
    There are a bunch of recipes around for limiting the number of forks running at any one time, but you are best off using Parallel::ForkManager See: controlling child processes

    I'm not really a human, but I play one on earth Remember How Lucky You Are