_NutHandleToFd()

return new file descriptor corresponding to Win32 handle 

Function


SYNOPSIS

#include <winnutc.h>

int _NutHandleToFd(HANDLE handle, int flags, const char *path);


DESCRIPTION

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 PTC 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.


PARAMETERS

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.


RETURN VALUES

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.


CONFORMANCE

PTC MKS Toolkit UNIX APIs extension.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
_NutFdToHandle(), open()


PTC MKS Toolkit 10.3 Documentation Build 39.