import signal


def translate_rc(rc):
    """
    Accept an rc encoded as for subprocess.Popen.returncode:
    None means still running
    int >= 0 means terminated voluntarily with specified rc
    int <  0 means terminated by signal (-rc)

    Return a string explaining the outcome. In case of a signal, try to
    name the corresponding symbol from the 'signal' module.
    """
    if rc is None:
        return "still running"
    
    if rc >= 0:
        return "terminated with rc %s" % rc

    # Negative rc means the child was terminated by signal -rc.
    rc = -rc
    for attr in dir(signal):
        if attr.startswith('SIG') and getattr(signal, attr) == rc:
            strc = attr
            break
    else:
        strc = str(rc)
    return "terminated by signal %s" % strc