- Define `_POSIX_C_SOURCE 200809L` or `_XOPEN_SOURCE 700` before any includes to enable POSIX.1-2008 APIs consistently.
- Always check return values from POSIX calls (`open`, `read`, `write`, `close`) and handle `EINTR` by retrying the call in a loop.
- Use `opendir`/`readdir`/`closedir` for directory traversal and `stat`/`fstat` for file metadata — never parse `/proc` or shell output.
- Prefer `pthreads` (`pthread_create`, `pthread_mutex_lock`) for threading — always pair `pthread_mutex_lock` with `pthread_mutex_unlock`.
- Use `sigaction()` instead of `signal()` for reliable, portable signal handling — `signal()` behavior varies across platforms.
- Use `poll()` or `select()` for multiplexed I/O — prefer `poll()` as it has no `FD_SETSIZE` limit and cleaner semantics.
- Use `pipe()` for inter-process communication and `dup2()` for file descriptor redirection in child processes after `fork()`.
- Prefer `posix_spawn()` over `fork()`+`exec()` in multi-threaded programs — `fork()` only copies the calling thread, leaving mutexes in undefined states.
- Use `mmap()` with `MAP_PRIVATE` for read-only file access and `MAP_SHARED` for inter-process shared memory.