File descriptor là abstraction cốt lõi của Linux I/O; pipe là unidirectional IPC qua kernel buffer; /proc là virtual FS cho phép introspect kernel state — ba concept liên kết chặt với nhau.
File Descriptor (FD): là integer đại diện cho open file/socket/pipe/device. Process bắt đầu với 3 FDs: 0 (stdin), 1 (stdout), 2 (stderr). ulimit -n show max FDs per process (default 1024, production nên tăng lên 65536+). Leak FD: process mở file/socket nhưng không close → FD exhaustion → Too many open files. Check: lsof -p PID | wc -l. Pipe: anonymous pipe | trong shell — kernel buffer (thường 65536 bytes), unidirectional, một đầu write (stdout của process A), một đầu read (stdin của process B). Named pipe (FIFO): tồn tại trong filesystem, không cần parent-child. /proc filesystem: virtual filesystem kernel expose information: /proc/PID/fd/ (FDs của process), /proc/PID/maps (memory mapping), /proc/PID/status (process info), /proc/meminfo (RAM usage), /proc/cpuinfo, /proc/net/tcp (TCP connections). Mọi thứ là file — cat /proc/1/cmdline là command của init process. Docker stats đọc từ /proc và cgroups.
File descriptors are the core abstraction of Linux I/O; pipes are unidirectional IPC via kernel buffers; /proc is a virtual FS for introspecting kernel state — three closely linked concepts.
File Descriptor (FD): an integer representing an open file, socket, pipe, or device. A process starts with 3 FDs: 0 (stdin), 1 (stdout), 2 (stderr). ulimit -n shows the max FDs per process (default 1024; production systems should increase this to 65536+). FD leak: a process opens a file/socket but never closes it → FD exhaustion → 'Too many open files'. Check with: lsof -p PID | wc -l. Pipe: the anonymous pipe | in a shell — a kernel buffer (typically 65536 bytes), unidirectional, with one end for writing (stdout of process A) and one for reading (stdin of process B). Named pipe (FIFO): persists in the filesystem and does not require a parent-child relationship. /proc filesystem: a virtual filesystem where the kernel exposes information: /proc/PID/fd/ (FDs of a process), /proc/PID/maps (memory mappings), /proc/PID/status (process info), /proc/meminfo (RAM usage), /proc/cpuinfo, /proc/net/tcp (TCP connections). Everything is a file — cat /proc/1/cmdline shows the init process command. Docker stats reads from /proc and cgroups.