Closed prashant-pokhriyal closed 5 years ago
Calling $pm->start_child( sub { ... })
is non-blocking. It'll launch the child and continue to do its thing.
As for checking on the child processes, the parent has the attribute processes
, which is a hashref whose keys are the pid of the children, and the values are the identifiers of those childrens (if any were given). So you can do something like:
for my $pid ( keys $self->processes->%* ) {
my $p = waitpid $pid, &WNOHANG;
# $p == -1 means its gone
}
Is there any way that I can keep running parent without blocking it? One more thing I want to check in the parent process whether a child is active or its get killed. If it gets terminated or killed I've to spawn it again.