Skip to content

Instantly share code, notes, and snippets.

@mtsmfm
Created May 11, 2022 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtsmfm/1214524c484ae2fa204fb4e8b09cff5a to your computer and use it in GitHub Desktop.
Save mtsmfm/1214524c484ae2fa204fb4e8b09cff5a to your computer and use it in GitHub Desktop.
graceful shutdown with child process
trap 'kill "${child_pid}"; wait ${child_pid}; exit' TERM INT
ruby -e 'at_exit { sleep 3; p "exit" }; loop { p "sleep"; sleep 1 }' &
child_pid="$!"
sleep infinity & wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment