Skip to content

Instantly share code, notes, and snippets.

@MikeDacre
Last active February 26, 2016 19:05
Show Gist options
  • Save MikeDacre/10ae23dcd3986793c3fd to your computer and use it in GitHub Desktop.
Save MikeDacre/10ae23dcd3986793c3fd to your computer and use it in GitHub Desktop.
#!/bin/bash
#SBATCH --partition=<partition>
#SBATCH --time=00:02:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --signal=b:USR1@10
trap_with_arg() {
func="$1" ; shift
for sig ; do
trap "$func $sig" "$sig"
done
}
func_trap() {
echo Trapped: $1
}
trap_with_arg func_trap 0 1 USR1 EXIT HUP INT QUIT PIPE TERM
cat /dev/zero > /dev/null &
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment