How to Pause (Suspend) a process in Linux with kill signalsKedarJanuary 9, 2018 In this post we will see how to pause (suspend) and start a linux process using signals (SIGTSTP and SIGCONT) via kill command. View Post
2 responses to “How to Pause (Suspend) a process in Linux with kill signals”
Hi there,
Your script could be improved somewhat, because if you only give it ‘start’ or ‘stop’ as parameter without a second parameter, it will happily execute a kill command, which will fail because the PID is missing.
For that, I suggest changing the line ‘if [ “$#” -eq 0 ]; then’ to ‘if [ “$#” -lt 2 ]; then’.
Secondly, the line under ‘usage() {‘ isn’t quite correct. I would suggest the following:
echo “$(basename $0) [stop|start] PID”
This way, the actual script name is shown, while the ‘basename’ makes sure the path to the script is left out.
Lastly, the semicolon after the last line isn’t necessary and looks a bit wacky because there is another line with ‘fi’ that isn’t followed by a semicolon, so the last line looks out of place.
Thank you for your inputs, Richard,
I was working on a PoC for something and this was one of the section of that which I found useful to share. That said, your recommendations are good. I will look to adjust this.
Cheers.