Message407216
In Windows, GetFileType((HANDLE)_get_osfhandle(fd)) is several times faster than close(dup(fd)). For example:
#if defined(MS_WINDOWS)
int type;
_Py_BEGIN_SUPPRESS_IPH
type = GetFileType((HANDLE)_get_osfhandle(fd));
_Py_END_SUPPRESS_IPH
return type != FILE_TYPE_UNKNOWN;
#endif
If the C file descriptor isn't assigned and flagged FOPEN, then _get_osfhandle() returns (intptr_t)-1. This is the pseudohandle value for the current process, so GetFileType() will fail with an invalid handle error, as expected. |
|
Date |
User |
Action |
Args |
2021-11-28 19:23:14 | eryksun | unlink | issue45915 messages |
2021-11-28 18:25:34 | eryksun | set | recipients:
+ eryksun, vstinner, christian.heimes |
2021-11-28 18:25:34 | eryksun | set | messageid: <1638123934.19.0.140847870252.issue45915@roundup.psfhosted.org> |
2021-11-28 18:25:34 | eryksun | link | issue45915 messages |
2021-11-28 18:25:34 | eryksun | create | |
|