]> git.ipfire.org Git - thirdparty/xz.git/commit
xz: Create separate is_tty() function.
authorJia Tan <jiat0218@gmail.com>
Thu, 23 Nov 2023 14:04:35 +0000 (22:04 +0800)
committerJia Tan <jiat0218@gmail.com>
Fri, 22 Dec 2023 12:02:06 +0000 (20:02 +0800)
commit0ecfaa6df91f7c37510f370295f593b9c0b88b98
tree1b0c01e26e0171d9f9a49e57f9c770d0cf2f45d6
parent9a300c9068015fae0651c0835ca36d481b472ddd
xz: Create separate is_tty() function.

The new is_tty() will report if a file descriptor is a terminal or not.
On POSIX systems, it is a wrapper around isatty(). However, the native
Windows implementation of isatty() will return true for all character
devices, not just terminals. So is_tty() has a special case for Windows
so it can use alternative Windows API functions to determine if a file
descriptor is a terminal.

This fixes a bug with MSVC and MinGW-w64 builds that refused to read from
or write to non-terminal character devices because xz thought it was a
terminal. For instance:

    xz foo -c > /dev/null

would fail because /dev/null was assumed to be a terminal.
src/xz/util.c
src/xz/util.h