check the pid is > 0 before calling waitpid()