Hi , I am using ForkManager module for multiprocessing in my code below : -
use Parallel::ForkManager; $pm = new Parallel::ForkManager($MAX_PROCESSES); foreach $data (@all_data) { # Forks and returns the pid for the child: my $pid = $pm->start and next; ... do some work with $data in the child process ... $pm->finish; # Terminates the child process } Under # do some work ...... I read a file to see if it exists or not. If it exists then perform some action. Same is repeated for every process by checking that file existence as primary thing.I run below code in child my $file = "/tmp/test"; die "\n Killed as filed doesnot exist \n" if(-e $file); However what happens is child creation doesnot stop and it it gets created and prints "Killed as filed doesnot exist" and exists What I require is to exit the parent as well BUT handle it gracefully. I dont want that if I kill parent, children also die abruptlyand cause data inconsistency. I was thinking of using run_on_finish() callback ,however how to handle it so that all process gracefully exits and also parent doesnot spawn any new child ? Thanks and Regards, Punit