diff --git a/src/win/handle.c b/src/win/handle.c index ba0af755..4f37f4c0 100644 --- a/src/win/handle.c +++ b/src/win/handle.c @@ -27,9 +27,15 @@ uv_handle_type uv_guess_handle(uv_file file) { - HANDLE handle = (HANDLE) _get_osfhandle(file); + HANDLE handle; DWORD mode; + if (file < 0) { + return UV_UNKNOWN_HANDLE; + } + + handle = (HANDLE) _get_osfhandle(file); + switch (GetFileType(handle)) { case FILE_TYPE_CHAR: if (GetConsoleMode(handle, &mode)) {