
Mach Traps vs BSD System Calls on macOS
Learn how macOS routes one trap instruction to either a Mach trap or a BSD system call, how the number sign and class decide, and why you should call libSystem.
Everything you need to level up your coding skills.

Learn how macOS routes one trap instruction to either a Mach trap or a BSD system call, how the number sign and class decide, and why you should call libSystem.

How Mach ports, port rights and mach_msg work on macOS 15, with a complete client and server in C using the bootstrap server, plus where XPC sits on top.

Choose between DriverKit, system extensions and legacy kexts on macOS 15: what each runs in, what it can reach, how it installs, and a decision table.

How XNU combines Mach, a BSD layer and IOKit in one kernel: what each part owns, how a process maps to a task, and how a read call crosses all three.

Read kernel and driver messages on macOS 15 with log show and log stream, using predicates on process, subsystem and message text, plus time ranges and levels.

Read macOS kernel state from Terminal with sysctl and ioreg: hardware sizes, boot time, the device registry, USB devices, and how to filter the output.

Read and write files in Rust safely with std::fs and BufReader, understanding why unbuffered reads are slow and how Result propagation replaces manual checks.

atexit registers cleanup functions that run in reverse order when a program ends normally. on_exit also passes the status. Neither runs after _exit or abort.

Load a kernel module at every boot with /etc/modules-load.d and set its options in /etc/modprobe.d; the file formats, ordering, initramfs and how to verify.

getauxval reads the kernel's auxiliary vector: page size, CPU features, secure-mode flag, random bytes and the executable name, without parsing /proc.

Package an out-of-tree kernel module with DKMS: write dkms.conf, add, build and install, rebuild on kernel upgrades automatically and sign for Secure Boot.

Compare a module's vermagic string with uname -r using modinfo to see why insmod says Invalid module format, and what the version magic and CRC checks protect.
We send one email when a new post is published. No spam.