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]}) thepid=$(cat ${pidfile[$x]})
if [[ -n $thepid ]]; then if [[ -n $thepid ]]; then
sudo kill $thepid sudo kill $thepid
sleep 2 # give it some time wait $thepid # wait for the process to end
res=$(ps -p $thepid 2>&1) if [[ $? -eq 0 ]]; then
if [[ $? -ne 0 ]]; then
rm -f "${pidfile[$x]}" rm -f "${pidfile[$x]}"
rv=0 rv=0
else else