fix when isatty() cannot find valid file descriptor