Attach a file descriptor to a file handle
#include <sys/dispatch.h>
int select_attach
( void *dpp,
select_attr_t *attr,
int fd,
unsigned flags,
int (*func)( select_context_t *ctp,
int fd,
unsigned flags,
void *handle ),
void *handle );
libc
The function select_attach() attaches the file descriptor fd to the dispatch handle dpp and selects flags events. When fd "unblocks", func is called with handle.
Here's what the select_attr structure looks like:
typedef struct _select_attr {
unsigned flags;
} select_attr_t;
Currently, no attribute attr->flags are defined.
The available flags are defined in <sys/dispatch.h>. The following flags use ionotify() mechanisms (see ionotify() for further details):
These flags are specific to dispatch:
The argument func is the user-supplied function that's called when one of the registered events occurs on fd. This function should return 0 (zero), other values are reserved. The function is passed the following arguments:
See the flags section above for descriptions of the flags passed to func.
The argument handle is a pointer to data that's passed to func.
Zero on success, or -1 if an error occurred (errno is set).
For an example with select_attach(), see dispatch_create(). For other examples using the dispatch interface, see message_attach(), resmgr_attach(), and thread_pool_create().
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Interrupt handler | No |
| Signal handler | No |
| Thread | Yes |
select_detach(), select_query()