1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

tools/jlink: Exit terminal on Ctrl+C

This commit is contained in:
Leandro Lanzieri 2019-05-29 09:18:52 +02:00
parent 07131b4e4d
commit 79c095ef46

View File

@ -236,15 +236,16 @@ do_term() {
JLINK_PIDFILE=$(mktemp -t "jilnk_pid.XXXXXXXXXX")
# will be called by trap
cleanup() {
JLINK_PID="$(cat ${JLINK_PIDFILE})"
kill ${JLINK_PID}
rm -r "${JLINK_PIDFILE}"
if [ -f $JLINK_PIDFILE ]; then
JLINK_PID="$(cat ${JLINK_PIDFILE})"
kill ${JLINK_PID}
rm -r "${JLINK_PIDFILE}"
fi
exit 0
}
# cleanup after script terminates
trap "cleanup ${JLINK_PIDFILE}" EXIT
# don't trapon Ctrl+C, because JLink keeps running
trap '' INT
trap "cleanup ${JLINK_PIDFILE}" EXIT INT
# start Jlink as RTT server
sh -c "${JLINK} ${JLINK_SERIAL} \
-ExitOnError 1 \