From b0db6fb3aef2b9c24ad68470e40008f0cb0fc8cd Mon Sep 17 00:00:00 2001 From: rany Date: Mon, 24 May 2021 22:45:26 +0300 Subject: [PATCH] add pid check --- easy-playback.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/easy-playback.sh b/easy-playback.sh index 3656c44..45714b5 100755 --- a/easy-playback.sh +++ b/easy-playback.sh @@ -27,10 +27,13 @@ else stdin="" fi edge-tts "${@}" >"$ttsmpeg" <<<"$stdin" & +edgePID=$! ## Wait until temporary file has some data so mpg123 doesn't exit immediately ## because it thinks file is empty and won't have any data. -while [ "$(wc -c <"$ttsmpeg")" == 0 ] +## +## kill -0 checks if PID is still running. +while [ "$(wc -c "$ttsmpeg")" == 0 ] || kill -0 "$edgePID" 2>/dev/null do sleep 0.1 done