Skip to content

Instantly share code, notes, and snippets.

@martinda
Created November 23, 2018 14:27
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 martinda/2e5c6d10f441c61949d09936f43d83bf to your computer and use it in GitHub Desktop.
Save martinda/2e5c6d10f441c61949d09936f43d83bf to your computer and use it in GitHub Desktop.
How to kill a bash function and what it runs
#!/bin/bash
set -o xtrace
function task {
cat /dev/random >/dev/null
}
task & pid=$!
sleep 1
ps -fH
kill $pid
ps -fH
# At this point we see that the 'cat' is still running
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment