Portable version using P9Y::ProcessTable ... it works on win32 , probably works on other OS if par works the same there
BEGIN {
my $PAR_PROGNAME = "$ENV{PAR_TEMP}\\$ENV{PAR_ARGV_0}.exe"; ## hack
use P9Y::ProcessTable();
my $perl_process = P9Y::ProcessTable->process;
my $parentpid = $perl_process->ppid;
my $ExecutablePath = $perl_process->{exe};
undef $perl_process ;
no P9Y::ProcessTable();
sub IsParParentAlive {
(
$PAR_PROGNAME eq $ExecutablePath ## doublecheck
or
$ENV{PAR_SPAWNED}
)
and kill 0, $parentpid;
}
}