
질문이 있어요https://mywiki.wooledge.org/BashFAQ/106
이 코드를 살펴보세요:
exec > >(tee myfile)
pspid=$!
# ... stuff ...
echo "A"
cat file
echo "B"
# end stuff
# All done. Close stdout so the proc sub will terminate, and wait for it.
exec >&-
wait $pspid
# what happens if we delete line exec >&- ?
# what if ...stuff... do not finish before >&- ?
내 첫 번째 질문은 왜 이것이 여기에 필요한가요 exec >&-
? 삭제하면 어떻게 되나요? 삭제하면 무기한 대기가 exec >&-
발생할 것 같습니다 .wait $pspid
tee myfile
백그라운드에서 비동기적으로 실행 되기 때문에 stuff
순서가 잘못된 처리가 예상되었습니다. 두 번째 질문은 이 중 이전에 수행되지 않은 작업이 있으면 stuff
어떻게 됩니까 >&-
? 입니다.