01 · Why it’s true
User programs can’t touch hardware or kernel data directly. To open a file, send on a socket, or get more memory, they make a system call — a controlled switch into the kernel, which checks permissions and does the work on their behalf.
Because every interaction with the outside world goes through system calls, tracing them shows what a program is really doing: which files it opens, which call it’s stuck in, and which calls fail. Each crossing also has a cost, so many tiny reads or writes are slower than a few large ones.
02 · Picture it
03 · In the interview
- Using
straceto see what a stuck or failing process is doing. - Explaining why buffered I/O is faster than many tiny writes.
- Reading error codes like ENOENT, EACCES, and ECONNREFUSED.
04 · Practice question
“A process is hung and its logs say nothing. How do you find out what it’s doing?”
A strong answer covers
- Attach
strace -p <pid>to see which system call it’s blocked in — for example areadon a socket or afutexwait (a lock). - Map the file descriptor in that call to a file or connection with
ls -l /proc/<pid>/fdorlsof. - Get thread stacks too, with a language-level thread dump or a debugger.
- Use strace briefly in production: it slows the traced process down.