#!/bin/bash
declare -i i=0
declare SLEEP_FLAG=1
builtin trap '{ SLEEP_FLAG=1;while :;do ((${SLEEP_FLAG}))&&sleep 1||break;done;}' TSTP
builtin trap '{ SLEEP_FLAG=0;}' CONT ## Why don't all shell scripts do this??
builtin trap '{ echo -en "\nUseful addition to a shell script that may run for a while.\n";exit 0;}' INT
clear
while :; do
i+=1
if ((${i}%7==0)); then
echo -en "** Warning: file system is getting full ... ${i}"
sleep .5
clear
else
echo -en "looping around ... ${i}"
sleep .25
echo -en "\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r"
fi
((${i}==75)) && echo "Sending SIGTSTP to myself! To restart me \$>kill -SIGCONT $$" && kill -SIGTSTP $$
done
exit 0
Thursday, September 21, 2017
Bash Shell Simple Stop/Start Signal Handling
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment