csci4061/p2-code/cat-sig.sh
Michael Zhang 041f660ccd
f
2018-01-29 17:28:37 -06:00

13 lines
175 B
Bash
Executable file

#!/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}"