Skip to content

Glossary

Mach message

The unit of data and capability transfer between tasks on macOS. A header plus optional typed body that can move ports and memory pages atomically.

A Mach message is what travels through a Mach port. It has a fixed-size header plus an optional body of typed descriptors.

The header carries two ports — a remote (destination) and a local (where to reply) — which together are the entire addressing scheme for IPC on macOS. There is no PID, no name resolution: the kernel resolves the port reference to a queue and enqueues the message.

apple-oss-distributions/xnuosfmk/mach/message.h:430Layout of mach_msg_header_t. The whole IPC surface starts here.View on GitHub(line 430) apple-oss-distributions/xnuosfmk/ipc/mach_msg.cmach_msg_overwrite_trap — every send in the system goes through this.View on GitHub(line )

The descriptors in the body are what make Mach messages interesting: they can transfer port rights (capability passing between tasks) and out-of-line memory (a copy-on-write mapping handoff, not a memcpy). This is how XPC moves a file handle from one daemon to another in one syscall.

See also: Mach port, task.