security_SandboxedServices: Fix race condition

There is a race condition around the list of processes: if a
process dies after we established the list but before we parsed its
entry, we will be unable to parse and the test will fail like so:

04/11 10:06:23.602 ERROR|security_Sandboxed:0299| mtpd: missing seccomp usage: wanted 2 (filter) but got None (???)

BUG=chromium:710687
TEST=run the test

Change-Id: Ic7c0aac3fdd1f2893f17ea0f6ed64b374f653d8d
Reviewed-on: https://chromium-review.googlesource.com/475050
Commit-Ready: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Alexander Alekseev <alemate@chromium.org>
diff --git a/client/site_tests/security_SandboxedServices/security_SandboxedServices.py b/client/site_tests/security_SandboxedServices/security_SandboxedServices.py
index 77ef6f4..697669e 100644
--- a/client/site_tests/security_SandboxedServices/security_SandboxedServices.py
+++ b/client/site_tests/security_SandboxedServices/security_SandboxedServices.py
@@ -111,9 +111,9 @@
         # Example line output:
         # Pid:1 CapInh:0000000000000000 CapPrm:0000001fffffffff CapEff:0000001fffffffff CapBnd:0000001fffffffff Seccomp:0
         cmd = (
-            "awk '$1 ~ \"^(Pid|%s):\" "
+            "for f in /proc/[1-9]*/status ; do awk '$1 ~ \"^(Pid|%s):\" "
             "{printf \"%%s%%s \", $1, $NF; if ($1 == \"%s:\") printf \"\\n\"}'"
-            " /proc/[1-9]*/status"
+            " $f ; done"
         ) % ('|'.join(STATUS_FIELDS), STATUS_FIELDS[-1])
         # Processes might exit while awk is running, so ignore its exit status.
         status_output = utils.system_output(cmd, ignore_status=True)