devserver: fix a bug when counting processes

The original code has a bug when run by Python 2.7.6 that it always
return 1 even there's no this process, see

Python 2.7.6 (default, Oct 26 2016, 20:30:19)
  [GCC 4.8.4] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import subprocess
  >>> p = subprocess.Popen('pgrep -fc "xxxx"', stdout=subprocess.PIPE,
      stderr=subprocess.PIPE, shell=True)
  >>> p.communicate()
  ('1\n', '')
  >>> p.wait()
  0
  >>> p = subprocess.Popen(['pgrep', '-fc',  "xxxx"],
      stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  >>> p.communicate()
  ('0\n', '')
  >>> p.wait()
  1

I don't have this issue when run above code with Python 2.7.16. I guess
it should be related to how subprocess runs a process in a shell.

BUG=chromium:961318
TEST=Ran local test

Change-Id: Ia2e06a58bea9c7a1581dab87441eb2d12cd59c1a
Reviewed-on: https://chromium-review.googlesource.com/1607084
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Congbin Guo <guocb@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/devserver.py b/devserver.py
index 99e12df..23dd503 100755
--- a/devserver.py
+++ b/devserver.py
@@ -1661,10 +1661,10 @@
       # Use Popen instead of check_output since the latter cannot run with old
       # python version (less than 2.7)
       proc = subprocess.Popen(
-          'pgrep -fc "%s"' % process_cmd_pattern,
+          ['pgrep', '-fc', process_cmd_pattern],
           stdout=subprocess.PIPE,
           stderr=subprocess.PIPE,
-          shell=True)
+      )
       cmd_output, cmd_error = proc.communicate()
       if cmd_error:
         _Log('Error happened when getting process count: %s' % cmd_error)