# a script that kills a second script could be written using:

#!/bin/sh
# execute a script that creates /tmp/job.pid
newscript &
trap 'kill -HUP $(cat /tmp/job.pid)' 0 HUP INT TERM
# continue on, waiting for the other to finish
# <rest of the script deleted>
