in reply to Re: Check if forked process is dead
in thread Check if forked process is dead

I'd like to know if I can check that process was not terminated by SIGTERM, so I'd SIGKILL it after some seconds. This doesn't work:
$ perl -Mstrict -MPOSIX -wE 'my $pid = fork; if( $pid ){ kill TERM => +$pid; waitpid $pid => WNOHANG; say kill 0 => $pid; } else { sleep 3; + exit; }' 1 $
But only 0 instead of WNOHANG shows me that process is ended.
Can I check if the process is ended in a limited amount of time?
Should I fork a new process only for a blocking waitpid $pid => 0 particularly?
Thank you.