#include <winnutc.h>
int _NutHandleToFd(HANDLE handle,
int flags, const char *path);
The _NutHandleToFd() function returns a new file
descriptor corresponding to the specified Win32 handle.
The specified flags are used to set the state of the new file descriptor,
corresponding to the specified path.
This is useful when integrating NuTCRACKER Platform code with Win32 native code, as the
resulting file descriptor can be used with functions found in the MKS Toolkit UNIX APIs.
The specified handle should not be closed with
CloseHandle(). The handle is closed by the NuTCRACKER Platform when
close() is called on the file descriptor (either
explicitly or when the process exits).
Be careful when sharing file descriptors between NuTCRACKER Platform and Win32 code.
If the Win32 code change settings on the underlying object
(for example, calls ioctl() on a socket handle obtained
from a NuTCRACKER Platform socket file descriptor), the NuTCRACKER Platform is unaware of those
changes, and program behavior for that handle/file descriptor is undefined.
Unless the handle and file descriptor are being shared simply for
I/O operations, and not control operations, once the file
descriptor has been used in NuTCRACKER Platform code, the corresponding handle should
not be used further in Win32 code.
This issue is especially important for sockets, as the NuTCRACKER Platform needs to
manipulate
the settings of WinSock sockets to ensure that socket operations are correctly
interruptible.
- handle
-
Is the Win32 file handle for which a new file descriptor is to be created.
- flags
-
Contains the flags describing the state of the file descriptor, as specified
for open().
- path
-
Is the path to the file corresponding to handle.
If the path is unknown, an empty string should be passed.
If successful, _NutHandleToFd()
returns a new file descriptor. On failure, it returns a value of
-1 and sets errno to one of the following values:
- EINTR
-
A signal interrupted the call.
- EMFILE
-
This process is currently using too many open file descriptors.
MKS Toolkit UNIX APIs extension.
MT-Safe.
None.
MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition
- Functions:
- _NutFdToHandle(), open()
MKS Toolkit 9.3 Documentation Build 6.