Improve waiting for vpn process to end

This commit is contained in:
Rob Pearce 2025-01-16 10:35:42 +11:00
parent 69fa9f3637
commit 6feae08810
1 changed files with 2 additions and 3 deletions

5
cvpn
View File

@ -433,9 +433,8 @@ elif [[ $cmd == "off" ]]; then
thepid=$(cat ${pidfile[$x]})
if [[ -n $thepid ]]; then
sudo kill $thepid
sleep 2 # give it some time
res=$(ps -p $thepid 2>&1)
if [[ $? -ne 0 ]]; then
wait $thepid # wait for the process to end
if [[ $? -eq 0 ]]; then
rm -f "${pidfile[$x]}"
rv=0
else