tty: untangle locking of wait_until_sent