tests: Store the correct PID in hostapd-test.pid file

Message ID 1534959105-13163-1-git-send-email-andrei.otcheretianski@intel.com
State New
Headers show
Series
  • tests: Store the correct PID in hostapd-test.pid file
Related show

Commit Message

Otcheretianski, Andrei Aug. 22, 2018, 5:31 p.m.
The ./start.sh script spawns hostapd process using "sudo".
Since sudo forks a child process, $! holds the pid of sudo itself.
Fix that by storing the PID of the child process instead.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 tests/hwsim/start.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch

diff --git a/tests/hwsim/start.sh b/tests/hwsim/start.sh
index 527ee22..7682fce 100755
--- a/tests/hwsim/start.sh
+++ b/tests/hwsim/start.sh
@@ -121,7 +121,10 @@  sudo $(printf -- "$VALGRIND_WPAS" 5) $WPAS -g /tmp/wpas-wlan5 -G$GROUP \
     -ddKt$TRACE -f $LOGDIR/log5 &
 sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -f $LOGDIR/hostapd &
 HPID=$!
-echo $HPID > $LOGDIR/hostapd-test.pid
+
+# Sleep a bit, otherwise pgrep may run before the child is forked
+sleep 0.1
+pgrep -P $HPID > $LOGDIR/hostapd-test.pid
 
 if [ -x $HLR_AUC_GW ]; then
     cp $DIR/auth_serv/hlr_auc_gw.milenage_db $LOGDIR/hlr_auc_gw.milenage_db