Linux Shell中捕获CTRL+C

#!/bin/bash

trap 'onCtrlC' INT
function onCtrlC () {
echo 'Ctrl+C is captured'
}

while true; do
echo 'I am working!'
sleep 1
done

posted @ 2019-08-06 10:11  mingzhang  阅读(3312)  评论(0编辑  收藏  举报