Skip to content

Instantly share code, notes, and snippets.

@purpleidea
Last active April 28, 2019 16:29
Show Gist options
  • Save purpleidea/79e18e66f42ff34d96d4a1fe835124d1 to your computer and use it in GitHub Desktop.
Save purpleidea/79e18e66f42ff34d96d4a1fe835124d1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# james shubin, agplv3+
# pause until key press and then continue
# https://ttboj.wordpress.com/2017/01/06/ten-minute-hacks-process-pause-resume
if [ ! "$#" -eq 1 ]; then
echo "Usage: `basename $0` <process>"
echo "Pauses process until key press and then continues!"
exit 1
fi
echo "Stopping '$1'..."
killall -SIGSTOP "$1"
e=$?
if [ $e -ne 0 ]; then
echo "Could not pause '$1', error '$e'."
exit $e
fi
echo "[press any key to continue]"
#read -n1 -r -s -p "[press any key to continue]" key
read -n1 -r -s key
tput cuu 1 && tput el # remove last line
echo "Continuing '$1'..."
#echo # newline
killall -SIGCONT "$1"
exit $?
@joejulian
Copy link

imho, you should use the procps pkill rather than killall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment