Tools: Try to exit more gracefully from fuzzing.

If we catch a signal while we're fuzzing, exit with a successful status
and clean up after ourselves.


(cherry picked from commit dacbfc4ae9)
This commit is contained in:
Gerald Combs 2021-05-11 10:56:10 -07:00
parent b45185f1c0
commit 5254d5e822
2 changed files with 10 additions and 3 deletions

View File

@ -150,8 +150,9 @@ echo ""
# Clean up on <ctrl>C, etc
trap_all() {
DONE=true
echo 'Caught signal'
printf '\n\nCaught signal. Exiting.\n'
rm -f "$TMP_DIR/$TMP_FILE" "$TMP_DIR/$ERR_FILE"*
exit 0
}
trap_abrt() {

View File

@ -83,8 +83,14 @@ echo "($HOWMANY)"
echo "Running $RANDPKT with args: $RANDPKT_ARGS"
echo ""
trap "MAX_PASSES=1; echo 'Caught signal'" HUP INT TERM
# Clean up on <ctrl>C, etc
trap_all() {
printf '\n\nCaught signal. Exiting.\n'
rm -f "$TMP_DIR/$TMP_FILE" "$TMP_DIR/$ERR_FILE"
exit 0
}
trap trap_all HUP INT TERM ABRT
# Iterate over our capture files.
PASS=0