Creates an XPC object representing a POSIX file descriptor.
- macOS 10.7+
- Mac Catalyst 13.0+
The file descriptor which is to be boxed.
A new file descriptor object. NULL if sufficient memory could not be allocated or if the given file descriptor was not valid.
This method performs the equivalent of a dup(2) on the descriptor, and thus it is safe to call close(2) on the descriptor after boxing it with a file descriptor object.
IMPORTANT: Pointer equality is the ONLY valid test for equality between two file descriptor objects. There is no reliable way to determine whether two file descriptors refer to the same inode with the same capabilities, so two file descriptor objects created from the same underlying file descriptor number will not compare equally with xpc_equal(). This is also true of a file descriptor object created using xpc_copy() and the original.
This also implies that two collections containing file descriptor objects cannot be equal unless the exact same object was inserted into both.