csci4061/p2-code/cat-sig.sh

14 lines
175 B
Bash
Raw Normal View History

2018-01-29 23:28:37 +00:00
#!/bin/bash
# Works like cat but handles SIGTERM gracefully
handle_term() {
exit 0
}
trap 'handle_term' TERM
while read line
do
echo "$line"
done < "${1:-/dev/stdin}"