Implementing infinite wait in shell scripting

前端 未结 7 697
独厮守ぢ
独厮守ぢ 2021-02-05 04:30

This may sound trivial, but I\'m pretty sure this question hasn\'t been asked, or at least I can\'t find it.

I\'m looking for a way to construct an infinite wait

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-05 05:11

    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
    

提交回复
热议问题