Examples of how to kill all child jobs when a shell script exits.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
266 B

  1. #!/bin/sh
  2. set -e
  3. DIR=$(dirname "$0")
  4. . "$1"
  5. # Set up child jobs
  6. "$DIR/wait_for_pid_exit.sh" job $$ &
  7. "$DIR/wait_for_pid_exit.sh" disowned $$ &
  8. builtin disown || echo "shell does not support disown"
  9. # Wait for jobs to actually start.
  10. sleep 0.01s
  11. kill_child_jobs