Intermediate LevelLinux Commands & SysAdmin
How does strace trace process system calls and signal handling for low-level debugging?
❓ Interview Prompt: Explain strace, system calls (openat, read, write, connect), attaching to active PIDs (-p), filtering syscalls (-e), and summary metrics (-c).
'strace' (System Call Trace) is a low-level diagnostic tool that intercepts and logs all system calls (syscalls) executed between a user-space process and the Linux kernel:
Common Use Cases:
•
Diagnose Missing Config Files: Trace file access attempts ('openat').
•
Inspect Network Connect Failures: Trace socket calls ('connect').
•
Profile Syscall Time: 'strace -c <command>' generates summary breakdown.
Code Implementation Example
bash
# Trace system calls of running process PID 4567
sudo strace -p 4567
# Filter only file open and stat system calls
sudo strace -e trace=openat,stat -p 4567
# Generate time summary breakdown of system calls
strace -c php script.php💡Tracing low-level process system calls using strace.
🎯 Interview Key Takeaway
Use strace -p <PID> to inspect exact system calls (openat, connect) executed by frozen or failing processes.
#strace#System Calls#Debugging#Kernel#Intermediate
Back to all Linux Commands & SysAdmin Questions→