A system administrator is troubleshooting a service that fails during startup. The service is known to fork multiple child processes, and the administrator suspects one of them is causing the failure. Which of the following commands would be most effective for tracing the system calls of the main process and all of its forked child processes?
The correct command is strace -f /path/to/service. The -f option instructs strace to trace child processes as they are created by the process currently being traced. This is essential for debugging applications that fork, as it provides a complete view of all system calls made by the parent and its children.
strace -p $(pidof service) is incorrect because it attaches to an already running process. Since the service is failing on startup, it would be difficult or impossible to capture the PID before it crashes. Also, this command does not trace forked processes by default.
strace -c /path/to/service is incorrect because the -c option only provides a summary of system call counts, times, and errors upon termination. It does not show the sequence of calls that led to the failure.
strace -e trace=openat /path/to/service is incorrect because while the -e option is useful for filtering specific system calls (like openat), it is too narrow for this scenario. The administrator does not yet know which system call is failing, and this command would miss other potentially problematic calls. Crucially, it also does not trace forked processes.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the `-f` option in `strace` do?
Open an interactive chat with Bash
Why is `strace -p $(pidof service)` not suitable for startup failures?
Open an interactive chat with Bash
Can `strace -c` be used to debug system call failures?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access