Skip to content

Commit 12a56d3

Browse files
authored
Merge pull request #65 from coursehero/64-support-ctrl-c
Abort the process when SIGINT, SIGTERM and SIGKILL are notified
2 parents cc54554 + eceb388 commit 12a56d3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

slacktee.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ function get_ok_in_response() {
8080
echo "$(echo "$response" | awk 'match($0, /"ok":([^,}]+)/) {print substr($0, RSTART+5, RLENGTH-5)}')"
8181
}
8282

83+
function handle_signal()
84+
{
85+
cleanup
86+
err_exit 1 "Aborting"
87+
}
88+
8389
function cleanup()
8490
{
8591
[[ -f $filename ]] && rm "$filename"
@@ -737,7 +743,7 @@ function main()
737743
parse_args "$@"
738744
setup_environment
739745
check_configuration
740-
trap cleanup SIGINT SIGTERM SIGKILL
746+
trap handle_signal SIGINT SIGTERM SIGKILL
741747

742748
text=""
743749
if [[ -n "$title" || -n "$link" ]]; then

0 commit comments

Comments
 (0)