Implementing infinite wait in shell scripting

前端 未结 7 695
独厮守ぢ
独厮守ぢ 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:12

    #!/bin/sh
    at_term() {
      echo 'Terminated.'
      exit 0
    }
    trap at_term TERM
    echo $$
    while true; do
      sleep 20 &
      wait $!
    done
    

提交回复
热议问题