python-linux-procfs: pflags: Handle pids that completed

Sometimes pids disappear when they are completed.

Programs such as pflags that use procfs must account for that.
The solution is to simply recognize this situation, and to continue.

Reviewed-by: Leah Leshchinsky <lleshchi@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
diff --git a/pflags b/pflags
index 3407b6f..46d396c 100755
--- a/pflags
+++ b/pflags
@@ -50,14 +50,25 @@
         pids = list(ps.processes.keys())
 
     pids.sort()
-    len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids if pid in ps]
+    len_comms = []
+    for pid in pids:
+        if pid in ps:
+            try:
+                len(ps[pid]["stat"]["comm"])
+            except (TypeError, FileNotFoundError):
+                continue
+            len_comms.append(len(ps[pid]["stat"]["comm"]))
+
     max_comm_len = max(len_comms, default=0)
     del len_comms
 
     for pid in pids:
         if pid not in ps:
             continue
-        flags = ps[pid].stat.process_flags()
+        try:
+            flags = ps[pid].stat.process_flags()
+        except AttributeError:
+            continue
         # Remove flags that were superseeded
         if "PF_THREAD_BOUND" in flags and "PF_NO_SETAFFINITY" in flags:
             flags.remove("PF_THREAD_BOUND")