_get_osfhandle
Retrieves the operating-system file handle that is associated with the specified file descriptor.
intptr_t _get_osfhandle(
int fd
);
Parameters
- fd
An existing file descriptor.
Return Value
An operating-system file handle if fd is valid. Otherwise, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, this function returns INVALID_HANDLE_VALUE (–1) and sets errno to EBADF, indicating an invalid file handle.
Remarks
To close a file opened with _get_osfhandle, call _close. The underlying handle is also closed by a call to _close, so it is not necessary to call the Win32 function CloseHandle on the original handle.
Requirements
Routine |
Required header |
---|---|
_get_osfhandle |
<io.h> |
For more compatibility information, see Compatibility in the Introduction.
.NET Framework Equivalent
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.