# I often run gulp-livereload on a remote server using port forwarding with plink or putty.
# Putty and plink crash somewhat frequently when carrying on this process remotely.
# This function - executed in a different terminal on remote host cleans up any zombie gulp process and the parent shell -
# as these zombie processes prevent port forwarding from working when trying to restart gulp.
function killGulp {
# necessary otherwise when piping ps output through grep,
# output includes grep command to find gulp
p=`mktemp`
ps alx > $p
findgulp=($(grep "gulp\s" $p))
# gulp process id
pid=${findgulp[2]}
# parent bash process id
ppid=${findgulp[3]}
kill -s SIGKILL $pid &>/dev/nul
kill -s SIGKILL $ppid &>/dev/nul
}
killGulp