Linux System Programming Fundamentals
This two-day workshop provides a solid understanding of the operating system architecture and low-level interfaces (principally, system calls and library functions) that are required to build system-level applications on Linux (and UNIX) systems. By completion of the workshop, participants will have a good understanding of the construction of many common Linux and UNIX programs (e.g., the shell, ls(1), and cp(1))
(+) Topics marked with a plus sign will be covered as time permits.
1. Fundamental concepts
* System calls and library functions
* Error handling
* System data types
2. File I/O
* File descriptors
* I/O system calls: open(), close(), read(), write()
* Seeking to a file offset: lseek(); file holes
* Relationship between file descriptors and open files
* Duplicating file descriptors
* Open file status flags
* I/O buffering in stdio and the kernel
3. File attributes
* Retrieving file information: stat()
* File ownership and permissions
* Changing file attributes
4. Directories and links (+)
* Hard and soft (symbolic) links
* Current working directory
* System calls and library functions for working with directories and links
* Process ID and parent process ID
* Memory layout of a process
* Command-line arguments
* Environment list
6. Process Credentials
* Password and group file
* User and group IDs
* Process credentails: real and effective IDs; supplementary group IDs
* Retrieving process credentials
* Signal types and default actions
* Setting signal dispositions
* Signal handlers
* Blocking signals (the signal mask); pending signals
* Designing signal handler functions
* Reentrant and async-signal-safe functions
8. Process lifecycle
* Process creation: fork()
* File descriptors and fork()
* Process termination: exit(3) and _exit(2)
* Monitoring child processes: wait(), waitpid()
* Orphans and zombies
* The SIGCHLD signal
9. Executing programs
* Executing a program: execve()
* The exec() library functions
* File descriptors and exec()
10. Privileged programs (+)
* Set-user-ID and set-group-ID programs
* Changing process credentials
11. Using pipes and FIFOs for interprocess communication (+)
* Creating and using pipes
* Using pipes to connect filters
* Semantics of I/O on pipes and FIFOs
The following people are likely to find the workshop of particular benefit:
* Programmers developing system-level applications for Linux systems, or programmers porting such applications from other operating systems (e.g., Windows) to Linux.
* Embedded programmers developing applications for Linux, or porting embedded applications from systems such as VxWorks or QNX to Linux.
* DevOps engineers and sytem administrators who want to gain a greater insight into the oepration of Linux applications.
The workshop consists of a mixture of detailed presentations coupled with many coding exercises that allow participants to apply the knowledge learned in the presentations.
* You should have a good reading knowledge of C or C++. For the practical sessions, templates will be provided to relieve you of the need to type in tedious boilerplate code. The templates are in C, but if you wish, it is also possible to complete the exercises in another suitable language such as D, Rust, or of course C++.
* You should have a basic familiarity with the Linux/UNIX command line to do tasks such as listing directories, editing files, and compiling programs.
* No previous system programming experience is assumed.
You'll need a laptop with Linux installed--either as a native install or inside a virtual machine (VM). In the latter case, you should ensure that the VM has working Internet access. The system should have a C compiler (e.g., gcc) and "make" installed. (It's likely that both of these are provided as part of the default install, if you are setting up a new system.)
Michael Kerrisk is a programmer, writer, and trainer who has a passion for investigating and explaining software systems. He is the author of "The Linux Programming Interface", a widely acclaimed book on Linux (and UNIX) system programming. He has been actively involved in the Linux development community since 2000, operating mainly in the area of testing, design review, and documentation of kernel-user-space interfaces. Since 2004, he has maintained the Linux "man-pages" project, which provides the primary documentation for Linux system calls and C library functions. Michael is a New Zealander, living in Munich, Germany, from where he operates a training business (man7.org) providing low-level Linux programming courses in Europe, North America, and occasionally further afield.