File tree 1 file changed +10
-12
lines changed
1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -2182,23 +2182,21 @@ is_valid_fd(int fd)
2182
2182
#if defined(F_GETFD ) && ( \
2183
2183
defined(__linux__ ) || \
2184
2184
defined(__APPLE__ ) || \
2185
- defined(MS_WINDOWS ) || \
2186
2185
defined(__wasm__ ))
2187
- int res ;
2188
- _Py_BEGIN_SUPPRESS_IPH
2189
- res = fcntl (fd , F_GETFD );
2190
- _Py_END_SUPPRESS_IPH
2191
- return res >= 0 ;
2192
- #elif defined(__linux__ ) || defined(MS_WINDOWS )
2193
- int fd2 ;
2194
- _Py_BEGIN_SUPPRESS_IPH
2195
- fd2 = dup (fd );
2186
+ return fcntl (fd , F_GETFD ) >= 0 ;
2187
+ #elif defined(__linux__ )
2188
+ int fd2 = dup (fd );
2196
2189
if (fd2 >= 0 ) {
2197
2190
close (fd2 );
2198
2191
}
2199
- _Py_END_SUPPRESS_IPH
2200
-
2201
2192
return (fd2 >= 0 );
2193
+ #elif defined(MS_WINDOWS )
2194
+ HANDLE hfile ;
2195
+ _Py_BEGIN_SUPPRESS_IPH
2196
+ hfile = (HANDLE )_get_osfhandle (fd );
2197
+ _Py_END_SUPPRESS_IPH
2198
+ return (hfile != INVALID_HANDLE_VALUE
2199
+ && GetFileType (hfile ) != FILE_TYPE_UNKNOWN );
2202
2200
#else
2203
2201
struct stat st ;
2204
2202
return (fstat (fd , & st ) == 0 );
You can’t perform that action at this time.
0 commit comments