Linux libc-Doku
Introduction
This collection provides a number of examples and cheatsheets for commonly used libc
functions and system calls for the Linux operating system. It gives a short description of each function and provides examples for their usage.
Functions are grouped in several categories, which cover specific use cases, respectively. For each category an overview of the involved functions and files is given followed by an example for the typical usage of these functions. After the usage example, a more detailed description of each function is given.
However, cheatsheets can not replace the thorough study of the corresponding manpages for more detailed information. Manpages can be retrieved using the following command:
Please use the following compiler flags for your exercises. These are the flags used to compile your Linux submissions.
CFLAGS = -std=c11 -pedantic -D_XOPEN_SOURCE=700 -Wall -Werror -O3
Cheatsheets (aka SPiC-Zettel)
- Errno Variable
Explanation of theerrno
variable. Memory
List of functions: malloc(), free()Functions to (de-)allocate memory.
Strings
List of functions: strlen(), strcpy(), strcat()Functions to analyze and manipulate C strings.
File System
List of functions:- directory handling: opendir(), closedir(), readdir()
- file handling: fopen(), fclose(), stat(), lstat()
Functions for file and directory handling (i.e., opening/closing files and retrieving metadata).
Input/Output
List of functions: printf(), fprintf(), fgetc(), fgets(), fputc(), fputs(), perror(), feof(), ferror()Functions for (formatted) input and output.
Processes
List of functions: exit(), wait(), waitpid(), fork(), execl(), execv(), execlp(), execvp(), strtok()Functions to create new processes and wait for the termination of processes. Furthermore, functions to execute a new program in a process.
Signals
List of functions: kill(), sigemptyset(), sigfillset(), sigaddset(), sigdelset(), sigismember(), sigprocmask(), sigaction(), sigsuspend()Functions to deliver, synchronize, and wait for POSIX signals in Linux.
Threads
List of functions: pthread_create(), pthread_exit(), pthread_join(), pthread_mutex_init(), pthread_mutex_lock(), pthread_mutex_unlock(), pthread_mutex_destroy()Functions to create, synchronize, and wait for POSIX threads (pthreads).
PDF Version
Here you can find and download a PDF version (and a compact PDF version optimized for printing) of this documentation.