fix fd assignment on tty close