Skip to content

Instantly share code, notes, and snippets.

@hno
Created July 24, 2023 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hno/cf3329680f6e4918252045e1d50e1cca to your computer and use it in GitHub Desktop.
Save hno/cf3329680f6e4918252045e1d50e1cca to your computer and use it in GitHub Desktop.
Delayed job control
#!/bin/bash
do_suspend=
handle_suspend() {
do_suspend=1
}
trap handle_suspend SIGTSTP
process_suspend() {
if ! [ $do_suspend ]; then
return
fi
trap - SIGTSTP
do_suspend=
kill -SIGTSTP $$
trap handle_suspend SIGTSTP
}
while true; do
for b in {0..999}; do
echo $((a++))
done
process_suspend
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment