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

原文地址:https://www.cnblogs.com/mingzhang/p/11307292.html