wait
Waits for any child process to terminate.
Suspends the current process until any child process terminates.
Returns the PID of the deceased child, or -1 if there are no
child processes. Sets $? to the wait status of the child
(encoding exit code and signal information).
Synopsis
my $pid = wait();
print "Child $pid exited with status $?\n";