I have below script running as background process.
#!/bin/sh while true; do : done email_kill_alert() { echo "" | mailx -s "scritp received kill signal." emailid } Above script is run as background process with nohup command. I want it to trigger email_kill_alert function to send out email as soon as script or process ID gets killed. I have been reading about use of trap but not sure how I implement it. Note that while loop is infinite as it constantly checks for a files.