Bird
0
0

Which signal is commonly used with trap to run cleanup code when a script exits normally?

easy🧠 Conceptual Q2 of 15
Bash Scripting - Error Handling
Which signal is commonly used with trap to run cleanup code when a script exits normally?
ASIGINT
BEXIT
CSIGKILL
DSIGSTOP
Step-by-Step Solution
Solution:
  1. Step 1: Identify signals for trap

    SIGINT is for interrupt, SIGKILL and SIGSTOP cannot be trapped, EXIT is a special pseudo-signal for script exit.
  2. Step 2: Choose the signal for normal exit cleanup

    EXIT runs commands when the script finishes normally or exits.
  3. Final Answer:

    EXIT -> Option B
  4. Quick Check:

    cleanup on exit = EXIT signal [OK]
Quick Trick: Use EXIT signal to trap script normal exit [OK]
Common Mistakes:
MISTAKES
  • Using SIGKILL which cannot be trapped
  • Confusing SIGINT (interrupt) with normal exit
  • Trying to trap SIGSTOP which is uncatchable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes