def _get_restore_function(self):
        """
        Return the binary function for restoring terminal attributes.
        :return: function (signal, frame) => None:
        """
        if os.name == 'nt' or not self.getch_enabled:
            return lambda signal, frame: None

        try:
            fd = self.stdin.fileno()
            initial = termios.tcgetattr(fd)
        except termios.error:
            return lambda signal, frame: None

        return lambda signal, frame: termios.tcsetattr(fd, termios.TCSADRAIN, initial)