How to use TTY from an application