Implementing infinite wait in shell scripting
If you have GNU coreutils, which accepts floating-point seconds, you can try:
sleep inf
This should block until the 64-bit timestamp wraparound.
Here's a solution without a loop:
#!/usr/local/bin/dash
echo $$
# -$$: kill process group (parent and children)
#trap 'trap - TERM; kill 0' TERM
#trap 'trap - INT TERM; kill 0' INT TERM
trap 'trap - TERM; kill -s TERM -- -$$' TERM
tail -f /dev/null & wait
exit 0
you can use a named pipe for your read:
mkfifo /tmp/mypipe
#or mknode /tmp/mypipe p
if you later want to send different arbitrary "signals" to the pipe, the read can be use in combination with a case statement to take appropriate actions (even useful ones)
while read SIGNAL; do
case "$SIGNAL" in
*EXIT*)break;;
*)echo "signal $SIGNAL is unsupported" >/dev/stderr;;
esac
done < /tmp/mypipe