
Limit a Process's Resources with setrlimit
Cap open files, CPU time, memory and core dumps for a Linux process with setrlimit, understand soft and hard limits, and read the results in /proc.
Processes, threads, files, memory mapping, signals, IPC and sockets through POSIX and Win32: the core every other kind of system is built on.

Cap open files, CPU time, memory and core dumps for a Linux process with setrlimit, understand soft and hard limits, and read the results in /proc.

Learn what Linux namespaces are, the eight kinds the kernel has, how to see them under /proc and how containers combine them to give a process its own view.

Fix the Too many open files error on Linux. Read RLIMIT_NOFILE, raise the soft limit in C, set systemd LimitNOFILE, and find the leak that caused it.

Open files with O_CLOEXEC so exec closes them automatically. Shows the leak into a child, the race with fcntl, and the flags for socket, pipe2 and dup3.

List the files a Linux process has open with ls -l /proc/PID/fd, read fdinfo for offsets and flags, and use lsof for whole-system questions, with a C version.

A file descriptor points to an open file description, which points to an inode. See which layer holds the offset, flags and data, with dup and fork demos.

Redirect stdout to a file in C by opening it and calling dup2 onto descriptor 1. Includes saving and restoring the terminal and the fork and exec case.

A file descriptor is a small integer that indexes a per-process table of open files. Learn what 0, 1 and 2 mean and how open and close hand numbers out.

Give a process its own root filesystem using CLONE_NEWNS, a private mount propagation and the pivot_root system call on Linux 6.12, with a complete C program.

Start a process that sees itself as PID 1 using clone with CLONE_NEWPID or unshare plus fork on Linux 6.12, and learn why unshare never moves the caller.

Lower or raise a process's nice value with nice and setpriority on Linux 6.12 and glibc 2.40, handle the -1 return trap, and know when root is required.

Read CPU time, peak memory, page faults and context switches for your own process with getrusage on Linux with glibc 2.40, and know which fields are filled.
We send one email when a new post is published. No spam.