BSD syscall#93
svc · unix #93
select
Waits for read, write or exceptional conditions on a set of file descriptors until a timeout expires.
Prototype
int select(int nd, u_int32_t *in, u_int32_t *ou, u_int32_t *ex, struct timeval *tv);Returns: int
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| nd | int | - | |
| in | u_int32_t | - | |
| ou | u_int32_t | - | |
| ex | u_int32_t | - | |
| tv | struct timeval | - |
Version history
| XNU tag | macOS | # |
|---|---|---|
| xnu-1456.1.26 | macOS 10.6 Snow Leopard | 93 |
| xnu-1486.2.11 | — | 93 |
| xnu-1504.15.3 | — | 93 |
| xnu-1504.3.12 | — | 93 |
| xnu-1504.7.4 | — | 93 |
| xnu-1504.9.17 | — | 93 |
| xnu-1504.9.26 | — | 93 |
| xnu-1504.9.37 | — | 93 |
Notes
Limited to fds below FD_SETSIZE (1024). On macOS kqueue scales much better and select is mostly retained for portability. Returns -1/EINTR on signal delivery unless SA_RESTART is set; the timeval is left unmodified.
Detection
syscall::select:entry in DTrace exposes fd-set bitmaps via arg pointers. lsof and Activity Monitor show processes waiting in select via wait channel selrec.
Related APIs
pollkqueuekeventpselectread