diff --git a/Libraries/LibCore/File.cpp b/Libraries/LibCore/File.cpp index 27f36fdd401..a2f26cf7eb0 100644 --- a/Libraries/LibCore/File.cpp +++ b/Libraries/LibCore/File.cpp @@ -7,15 +7,11 @@ #include #include -#include #if !defined(AK_OS_WINDOWS) # include #else -# include -# define STDIN_FILENO _fileno(stdin) -# define STDOUT_FILENO _fileno(stdout) -# define STDERR_FILENO _fileno(stderr) +# include #endif namespace Core { diff --git a/Libraries/LibCore/System.h b/Libraries/LibCore/System.h index 0a0b3eb122b..ed195985ba1 100644 --- a/Libraries/LibCore/System.h +++ b/Libraries/LibCore/System.h @@ -33,7 +33,11 @@ # include #else # include "SocketAddressWindows.h" +# include # define O_CLOEXEC O_NOINHERIT +# define STDIN_FILENO _get_osfhandle(_fileno(stdin)) +# define STDOUT_FILENO _get_osfhandle(_fileno(stdout)) +# define STDERR_FILENO _get_osfhandle(_fileno(stderr)) # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) using sighandler_t = void (*)(int); diff --git a/Libraries/LibCore/SystemWindows.cpp b/Libraries/LibCore/SystemWindows.cpp index d5b021bf9cf..b6a0e7e03c2 100644 --- a/Libraries/LibCore/SystemWindows.cpp +++ b/Libraries/LibCore/SystemWindows.cpp @@ -276,4 +276,9 @@ ErrorOr set_close_on_exec(int handle, bool enabled) return {}; } +ErrorOr isatty(int handle) +{ + return GetFileType(to_handle(handle)) == FILE_TYPE_CHAR; +} + }