Linux and UNIX system programming, system calls, and APIs based on The Linux Programming Interface.
Topics#
- File I/O: File descriptors, universal I/O model (
open,read,write,close,lseek), atomicity, andfcntl. - Process: Memory layout, creation (
fork), execution (exec), and termination (wait,waitpid). - Signals: Signal masks, handlers, and async-signal-safety.
- Threads: POSIX threads (
pthread), mutexes, and condition variables. - IPC: Pipes, FIFOs, POSIX/System V shared memory, message queues, and semaphores.
- Sockets: UNIX domain sockets and Internet domain (TCP/UDP) sockets.
- I/O Multiplexing: Scalable event-driven I/O (
epoll,select,poll). - Shared Libraries: Dynamic linking (
.so), runtime loading (dlopen,dlsym,dlvsym), and symbol interposition (LD_PRELOAD,RTLD_NEXT).
Reference & Lookup Tips#
- Manual Pages (
man):man 2 <syscall>: System calls (eg.man 2 open,man 2 read)man 3 <function>: C standard library functions (eg.man 3 perror,man 3 printf)
- System Headers (
/usr/include/):- Search constants and macro definitions directly using
$ grep -rn "<CONSTANT>" /usr/include/
- Search constants and macro definitions directly using
- Vim Man Lookup:
- Press
2K(or3K) on a function name in normal mode to open its man page directly within Vim
- Press
- Standard Exit Macros (
<stdlib.h>):exit(EXIT_SUCCESS): Successful termination (0)exit(EXIT_FAILURE): Unsuccessful termination (POSIX portability, preferred over magic numbers likeexit(1))