Answer the question
In order to leave comments, you need to log in
How not to stop script execution after trap?
this is the script. I want to be able to continue working after ctrl + c if the user did not confirm the exit
function after_ctrl_c() {
echo
# shellcheck disable=SC2162
read -p "do you want to stop the program? [yes/no]: " answer
case $answer in
y | yes | Y | YES)
echo Yes
exit
;;
*)
echo No
;;
esac
}
trap after_ctrl_c SIGINT
echo $$
while sleep 10
do
echo Sleeping
done
Answer the question
In order to leave comments, you need to log in
while sleep 10
do
echo Sleeping
done
while true; do
sleep 10
echo Sleeping
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question