use waitpid function