pipeline - Bash script fails to exit when pipelined to tee -


i have script following log file determine if server has started, , goes this:

echo "starting server." ./start_server.sh  sleeptime=0 while [ ${sleeptime} -lt 60 ]     sleep 5      serverlog=$(tail -n 5 ./server.log)     echo ${serverlog} | grep -iq "server startup"      if [ $? = 0 ]             echo "server startup successful"         exit 0     fi      let sleeptime=sleeptime+5 done  echo "warning: server startup status unknown." exit 1 

when run script (./start_server.sh), script exits fine. however, when pipeline tee (./start_server.sh | tee -a serverstartup.log), script doesn't end unless force (ctrl + c).

why doesn't script exit when pipelined tee?

the server script spawned child process never terminated because started daemon. tee waiting child process terminate, resulting in issue.

more details here: why tee wait subshells finish?


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -