[libvirt] [PATCHv2] waitpid: improve safety