Merge pull request #394 from markeissler/changelog-signal-trap

Handle signals in git-changelog.
This commit is contained in:
hemanth.hm 2015-07-16 09:25:45 +05:30
commit 8652172f9b

View file

@ -306,6 +306,28 @@ commitListPretty() {
commitList "$list_all" "$title_tag" "$start_tag" "$final_tag"
}
_exit() {
local pid_list=()
local defaultIFS="$IFS"
local IFS="$defaultIFS"
stty sane; echo; echo "caught signal, shutting down"
IFS=$'\n'
pid_list=( $(pgrep -P $$) )
IFS="$defaultIFS"
local _pid
for _pid in "${pid_list[@]}"; do
echo "killing: ${_pid}"
kill -TERM ${_pid}
done
wait; stty sane; exit 1
}
trap '_exit' SIGINT SIGQUIT SIGTERM
main() {
local start_tag="null" # empty string and "null" mean two different things!
local final_tag="null"
@ -433,6 +455,9 @@ main() {
else
mv -f "$tmpfile" "$changelog"
[[ -n "$GIT_EDITOR" ]] && $GIT_EDITOR "$changelog"
if [[ $? -ne 0 ]]; then
_exit
fi
fi
return