def process_exit_code(retval):
    """Process a waitpid returned exit code.

    :return: The exit code if it exit'd, the signal if it died from signalling.
    """
    if retval & 255:
        return (retval & 255) << 8
    return retval >> 8
