Why did you think it was strange? Successful return of killall
doesn't necessarily mean wpa_supplicant
has finished processing the incoming SIGTERM
signal. It's only that the signal was delivered to the wpa_supplicant
process, at best. Pehaps wpa_supplicant
needed some more time (such as sleep 1
) to finish execution of its clean-up handler (wpa_supplicant_terminate_proc()
in wpa_supplicant.c
)
- http://hostap.epitest.fi/cgit/hostap/tree/src/utils/eloop.c#n753
- http://hostap.epitest.fi/cgit/hostap/tree/wpa_supplicant/wpa_supplicant.c#n4033
So, I think you really need sleep 1
.
Update
I always rely on polling method like this
TIMEO=5
for ((i=0; i<TIMEO; ++i)); do
if pidof -s wpa_supplicant > /dev/null; then
sleep 1
else
break
fi
done
if ((TIMEO==i)); then
echo "timeout"
else
echo "it's gone"
fi
assuming there will not be multiple instances of wpa_supplicant
.