From 0f9783791b1bd32d3fc3678672e1fbbce1a965c1 Mon Sep 17 00:00:00 2001 From: Marc Jay Date: Fri, 8 May 2020 12:34:03 +0100 Subject: [PATCH] Support Ctrl-C/SIG INT stopping Prowler when running in Docker Trap Ctrl-C/SIG INT, call cleanup function and then exit, using the appropriate exit code Fixes #594 --- prowler | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/prowler b/prowler index cfa96a6b..37f13914 100755 --- a/prowler +++ b/prowler @@ -194,8 +194,19 @@ while getopts ":hlLkqp:r:c:g:f:m:M:E:enbVsSxI:A:R:T:w:" OPTION; do esac done +clean_up() { + rm -f /tmp/prowler*.policy.* +} + +handle_ctrl_c() { + clean_up + exit $EXITCODE +} + # Clean up any temp files when prowler quits unexpectedly -trap "{ rm -f /tmp/prowler*.policy.*; }" EXIT +trap clean_up EXIT +# Clean up and exit if Ctrl-C occurs. Required to allow Ctrl-C to stop Prowler when running in Docker +trap handle_ctrl_c INT . $PROWLER_DIR/include/colors . $PROWLER_DIR/include/os_detector