def METHOD_NAME(pid):
    '''wait for process to finish and return True upon success,
    False upon failure while logging the reason.'''
    pid_, status = os.waitpid(pid, 0)
    assert pid_ == pid
    if os.WIFEXITED(status):
        s = os.WEXITSTATUS(status)
        if not s:
            return True
        msg = 'exited with status {}'.format(s)
    elif os.WIFSIGNALED(status):
        s = os.WTERMSIG(status)
        msg = 'was killed with signal {} ({})'.format(s, signal.Signals(s).name)
    elif os.WIFSTOPPED(status):
        s = os.WSTOPSIG(status)
        msg = 'was stopped with signal {} ({})'.format(s, signal.Signals(s).name)
    else:
        msg = 'died of unnatural causes'
    treelog.error('process {} {}'.format(pid, msg))
    return False