fix a bug on tty