#!/bin/bash function x { echo trapped signal sleeping read -t 30 < /tmp/test.fifo echo done reading, exitting exit 0 } trap x SIGTERM rm -f /tmp/test.fifo mkfifo /tmp/test.fifo read < /tmp/test.fifo