Skip to content
systemcoding.dev
Topic

Systems Programming

Processes, threads, files, memory mapping, signals, IPC and sockets through POSIX and Win32: the core every other kind of system is built on.

Flat illustration of a browser and a server trading a request and a response, with the Linux, Rust and curl logos.
Systems Programming

Call POSIX APIs Safely with the nix Crate

Use the nix crate to call POSIX functions like pipe, fork, waitpid and kill from Rust with typed arguments, Result errors and no raw unsafe libc calls.

6 min read
Flat illustration of user space above the system call boundary, the kernel and the hardware, with the Rust, Linux and FreeBSD logos.
Systems Programming

How Rust's std Wraps libc and System Calls

Rust's standard library does not talk to the kernel directly on Linux. It calls libc, which issues the syscall. See the layers from File::open down to openat.

6 min read
Flat illustration of user space above the system call boundary, the kernel and the hardware, with the C, FreeBSD and Linux logos.
Systems Programming

Process Lines Efficiently with getline

Read lines of any length in C with getline, reuse one growing buffer, strip the newline, spot read errors and handle files without a final newline.

7 min read
Flat illustration of user space above the system call boundary, the kernel and the hardware, with the C, Rust and FreeBSD logos.
Systems Programming

Write Errors to stderr with perror and err

Report failures from a C tool the Unix way: perror, strerror and the err and warn family, with errno saved correctly and messages sent to stderr.

6 min read
Flat illustration of user space above the system call boundary, the kernel and the hardware, with the C, Rust and Linux logos.
Systems Programming

Read from stdin or a File Argument Like cat

Write a cat-style filter in C that reads the files named on the command line, uses standard input when there are none, and treats a lone hyphen as stdin.

7 min read
Flat illustration of user space above the system call boundary, the kernel and the hardware, with the Linux, FreeBSD and Rust logos.
Systems Programming

Exit Codes and Conventions for Unix Tools

What exit status 0, 1, 2, 126, 127 and 128 plus a signal number mean on Linux, how a shell reads them, and which codes your own command-line tool should return.

7 min read
Flat illustration of a database beside the table it holds, with the C, GNU and Rust logos.
Systems Programming

Parse Long Options with getopt_long

Use getopt_long in C to accept --name and --name=value options, fill in the option table, handle flags and abbreviations, and keep short options working.

7 min read
Flat illustration of user space above the system call boundary, the kernel and the hardware, with the C, Rust and Linux logos.
Systems Programming

Parse Command-Line Options with getopt

Learn how getopt walks argv in C, what optind, optarg and opterr mean, how a colon marks an option value, and how to handle errors and bundled flags.

8 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.