def write_main_socket(c):
    """Synchronous write to the main socket, wait for ACK"""
    the_stdin_thread.socket_write.send(c)
    while True:
        try:
            the_stdin_thread.socket_write.recv(1)
        except socket.error as e:
            if e.errno != errno.EINTR:
                raise
        else:
            break