Trace a process before stopping it
By the end: Inspect process identity and relationships, then stop only a process you started.
The idea
A PID identifies a process at a moment in time and can later be reused. A program name may match many processes. A signal is a request or notification; kill does not always mean immediate termination. Inspect the exact PID and prefer a graceful termination before considering a forced stop.
Your command toolkit
ps
What it solves: Take a snapshot of running processes.
ps -p "$$" -o pid,ppid,comm
Practice with evidence
- Predict the result
- Run the guided lab
- Compare the output
- Explain your choice
A worked example
Guided lab
sleep 60 &
si_job=$!
ps -p "$si_job" -o pid,ppid,comm
kill -TERM "$si_job"
wait "$si_job"
printf 'Child exit status: %s\n' "$?"
What to expect: You inspect and terminate your own sleep child. Bash normally reports status 143 for SIGTERM; it is expected here.
Make it yours: Explain why you captured $! immediately, how you checked the process, and why a name-based signal would have been broader.
Read further
- Debian reference: Linux fundamentals ↗www.debian.org
Apply what you learned
Your private practice
Answers are private. Completion requires the correct knowledge-check answer and a written response when an activity is included.
Restore a downloaded workbook
Choose a recovery file for this course and version. Review the recovered copy before saving it to your account.
Ask a question or report a problem
Describe what needs attention. Your private answer is shared only if you select the option below.