Created
July 24, 2023 22:18
-
-
Save hno/cf3329680f6e4918252045e1d50e1cca to your computer and use it in GitHub Desktop.
Delayed job control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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