Skip to content
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

NameTypeDirDescription
ndint-
inu_int32_t-
ouu_int32_t-
exu_int32_t-
tvstruct timeval-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard93
xnu-1486.2.1193
xnu-1504.15.393
xnu-1504.3.1293
xnu-1504.7.493
xnu-1504.9.1793
xnu-1504.9.2693
xnu-1504.9.3793

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