次のようなbashスクリプトがあります。
#!/bin/bash
startsomeservice &
echo $! > service.pid
while true; do
# dosomething in repeat all the time here
foo bar
sleep 5
done
# cleanup stuff on abort here
rm tmpfiles
kill $(cat service.pid)
このスクリプトの問題は、中止できないことです。ctrl+ci を押すと、次のループに入ります...このようなスクリプトを実行することは可能ですが、中止可能にすることはできますか?