BSD syscall#27
svc · unix #27
recvmsg
Receives a message and any ancillary control data into a scatter-gather buffer.
Prototype
int recvmsg(int s, struct msghdr *msg, int flags);Returns: int
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| s | int | - | |
| msg | struct msghdr | - | |
| flags | int | - |
Version history
| XNU tag | macOS | # |
|---|---|---|
| xnu-1456.1.26 | macOS 10.6 Snow Leopard | 27 |
| xnu-1486.2.11 | — | 27 |
| xnu-1504.15.3 | — | 27 |
| xnu-1504.3.12 | — | 27 |
| xnu-1504.7.4 | — | 27 |
| xnu-1504.9.17 | — | 27 |
| xnu-1504.9.26 | — | 27 |
| xnu-1504.9.37 | — | 27 |
Notes
recvmsg is the only way to receive ancillary objects: SCM_RIGHTS (file descriptor passing on AF_UNIX), SCM_CREDS (peer credentials), IP_RECVPKTINFO, and the NetworkExtension-specific NECP_CLIENT_RESULT family. The kernel fills msghdr.msg_flags with MSG_TRUNC if the iov was too small and MSG_CTRUNC if cmsg space was exhausted — callers must check both. macOS preserves message boundaries for SOCK_DGRAM and SOCK_SEQPACKET.
Detection
No ES coverage. Ancillary fd passing is observable via PROC_PIDFDSOCKETINFO snapshots before and after the call. NEFilterDataProvider sees payload bytes but not cmsg.
Related APIs
recvfromrecvmsg_xsendmsgsendmsg_xsocketpair