import signal
import errno


def _settable_signal(sig) -> bool:
    """Check whether provided signal may be set.
    """
    try:
        old = signal.signal(sig, lambda _num, _frame: ...)
    except OSError as e:
        # POSIX response
        assert e.errno == errno.EINVAL
        return False
    except ValueError as e:
        # Windows response
        assert e.args[0] == "invalid signal value"
        return False
    else:
        signal.signal(sig, old)
        return True