Perl waitpid Function
This function waits for the child process with ID PID to terminate, returning the process ID of the deceased process. If PID does not exist, then it returns -1. The exit status of the process is contained in $?.
The flags can be set to various values which are equivalent to those used by the waitpid() UNIX system call. A value of 0 for FLAGS should work on all operating systems that support processes.
Following is the simple syntax for this function −
waitpid PID, FLAGS
This function returns -1 if process does not exist else Process ID of deceased process.