Convert a file descriptor from Cygwin openat() to Win32 file HANDLE?

Mark Geisert mark@maxrnd.com
Mon Mar 4 06:59:00 GMT 2024


On 3/3/2024 10:16 PM, Cedric Blancher via Cygwin wrote:
> 
> How can I convert a file descriptor from Cygwin openat() to Win32 file HANDLE?

In general, this can be done with:
     hFile = (HANDLE) _get_osfhandle (int fd);

That works for simple cases such as disk file descriptors. I've learned 
one can't always depend on it because Cygwin can use several handles for 
a specific file or other object in certain situations, which I'm not 
going to list here because I don't know them all.

Try that and see if it works for your case.

..mark


More information about the Cygwin mailing list