From 6feae08810148844e7d69947721399c155ebda18 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Thu, 16 Jan 2025 10:35:42 +1100 Subject: [PATCH] Improve waiting for vpn process to end --- cvpn | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cvpn b/cvpn index 41fbe14..e2c3d2a 100755 --- a/cvpn +++ b/cvpn @@ -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