Fix hostapd shutdown timeouts

Fix a situation where the pgrep for hostapd sees the bash wrapper around
the pregp on the remote system, and never detects that hostapd is dead.

BUG=chromium:386336
TEST=network_WiFi_RateControl no longer times out during shutdown on a Leon in
the lab.
Change-Id: Iec2f5056c985f593cddf68301a7857392860886c
Reviewed-on: https://chromium-review.googlesource.com/206240
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index b0ac74e..bbd296b 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -45,7 +45,7 @@
         # Lab naming convention in: go/chromeos-lab-hostname-convention
         return wifi_test_utils.get_router_addr_in_lab(client_hostname)
 
-    raise error.TestError('Could not infer router hostname from client'
+    raise error.TestError('Could not infer router hostname from client '
                           'hostname: %s.' % client_hostname)
 
 
@@ -284,7 +284,7 @@
 
         """
         if instance is not None:
-            search_arg = '-f "%s.*%s"' % (process, instance)
+            search_arg = '-f "^%s.*%s"' % (process, instance)
         else:
             search_arg = process
 
@@ -294,7 +294,7 @@
         while not is_dead and time.time() - start_time < timeout_seconds:
             time.sleep(self.POLLING_INTERVAL_SECONDS)
             is_dead = self.host.run(
-                    'pgrep %s' % search_arg,
+                    'pgrep -l %s' % search_arg,
                     ignore_status=True).exit_status != 0
         if is_dead or ignore_timeouts:
             return is_dead
@@ -312,7 +312,7 @@
 
         """
         is_dead = self._kill_process_instance(
-                'hostapd',
+                self.cmd_hostapd,
                 instance=instance.conf_file,
                 timeout_seconds=30,
                 ignore_timeouts=True)
@@ -628,7 +628,7 @@
             if instance.dev_type == 'ibss':
                 self.iw_runner.ibss_leave(instance.interface)
             elif instance.dev_type == 'managed':
-                self._kill_process_instance('wpa_supplicant',
+                self._kill_process_instance(self.cmd_wpa_supplicant,
                                             instance=instance.interface)
             else:
                 self.iw_runner.disconnect_station(instance.interface)