4

In my bash script I am writing, I am trying to start a process (sleep) in the background and then suspend it. Finally, the process with be finished. For some reason through, when I send the kill command with the stop signal, it just keeps running as if it received nothing. I can do this from the command line, but the bash script is not working as intended.

sleep 15&
pid=$!
kill -s STOP $pid
jobs
kill -s CONT $pid
Jeremy
  • 45
  • 4

1 Answers1

3

You can make it work by enabling 'monitor mode' in your script: set -m

Please see why-cant-i-use-job-control-in-a-bash-script for further information

Community
  • 1
  • 1
Stephane Rouberol
  • 4,286
  • 19
  • 18
  • Thank you very much! I could not figure out why I could do it from the terminal, but not inside the script. – Jeremy Aug 16 '12 at 18:03