main-fn-win: fix handle validity check for XP

Apparently the standard handles can be set to bogus values on XP. Use
GetFileType to check whether they refer to an actual file/pipe/etc. The
logic used by is_valid_handle() is now pretty similar to what the CRT
uses to check for valid stdio handles.
This commit is contained in:
James Ross-Gowan 2015-04-11 14:35:50 +10:00
parent 1e3aad5f87
commit 96d0a3f56c
1 changed files with 2 additions and 1 deletions

View File

@ -14,7 +14,8 @@ int _dowildcard = 0;
static bool is_valid_handle(HANDLE h)
{
return h != INVALID_HANDLE_VALUE && h != NULL;
return h != INVALID_HANDLE_VALUE && h != NULL &&
GetFileType(h) != FILE_TYPE_UNKNOWN;
}
static bool has_redirected_stdio(void)