#!/bin/ksh trap huphandler HUP trap '' QUIT trap exithandler TERM INT huphandler() { print 'Received SIGHUP' } exithandler() { print 'Received SIGTERM or SIGINT' exit 1 } ## Execution starts here - infinite loop until interrupted while true; do sleep 5 print -n "$SECONDS " done