import signal


def signal_name(sig):
    """
    Return a string describing a signal number.

    EXAMPLES::

        sage: import signal
        sage: from sage.doctest.reporting import signal_name
        sage: signal_name(signal.SIGSEGV)
        'segmentation fault'
        sage: signal_name(9)
        'kill signal'
        sage: signal_name(12345)
        'signal 12345'
    """
    if sig == signal.SIGHUP:
        return "hangup"
    if sig == signal.SIGINT:
        return "interrupt"
    if sig == signal.SIGQUIT:
        return "quit"
    if sig == signal.SIGILL:
        return "illegal instruction"
    if sig == signal.SIGABRT:
        return "abort"
    if sig == signal.SIGFPE:
        return "floating point exception"
    if sig == signal.SIGKILL:
        return "kill signal"
    if sig == signal.SIGSEGV:
        return "segmentation fault"
    if sig == signal.SIGPIPE:
        return "broken pipe"
    if sig == signal.SIGALRM:
        return "alarm"
    if sig == signal.SIGTERM:
        return "terminate"
    if sig == signal.SIGBUS:
        return "bus error"
    return "signal %s"%sig