捕捉信号

5年以前  |  阅读数:490 次  |  编程语言:Shell 
#!/bin/bash

# testing signal trapping

trap "echo 'Sorry! I have trapped Ctrl-C'" SIGINT SIGTERM

echo this is a test program

count=1

while [ $count -le 10 ]
do
    echo "Loop #$count"
    sleep 5
    count=$[ $count+1 ]
done

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8