From 59e0a7610c708c0799b141715863167ed87babd8 Mon Sep 17 00:00:00 2001 From: Jakub Jankowski Date: Mon, 8 Jan 2018 03:49:26 +0100 Subject: Use pkill/pgrep Instead of heavy subshelling, use pkill/pgrep. Also, be a bit more specific on what we're killing. Signed-off-by: Jakub Jankowski --- rc.wireless | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rc.wireless b/rc.wireless index 3b09e2e..a4b20a1 100644 --- a/rc.wireless +++ b/rc.wireless @@ -110,8 +110,7 @@ is_wireless_device ${INTERFACE} || return 0 2> /dev/null || exit 0 # If we stop a wireless interface using wpa_supplicant, # we'll kill its wpa_supplicant daemon too and exit this script: if [ "$2" = "stop" ]; then - WPAPID=$(echo $(ps axww | grep wpa_supplicant | grep i${INTERFACE}) | cut -f1 -d' ') - [ ${WPAPID} ] && kill ${WPAPID} + pkill --full "bin/wpa_supplicant.* -i${INTERFACE}" return 0 fi @@ -294,8 +293,7 @@ if [ "$WPA" = "wpa_supplicant" ] || [ "$WPA" = "wpaxsupplicant" ] && [ -x ${SUPP [ ${WPA} = "wpaxsupplicant" ] && WPA_OPTIONS="${WPA_OPTIONS} -e" # Use external xsupplicant (disables the internal supplicant) # We leave a running wpa_supplicant process in peace: - WPAPID=$(echo $(ps axww | grep wpa_supplicant | grep i${INTERFACE}) | cut -f1 -d' ') - if [ ${WPAPID} ]; then + if pgrep --full "bin/wpa_supplicant.* -i${INTERFACE}" >/dev/null ; then echo "$0: wpa_supplicant found running already" | $LOGGER else echo "$0: wpa_supplicant -B -c${WPACONF} ${WPA_OPTIONS} -i$INTERFACE" | $LOGGER -- cgit v1.2.3