add pid and ppid to GUI
Stefan Schuermans

Stefan Schuermans commited on 2020-07-02 18:46:48
Showing 2 changed files, with 28 additions and 6 deletions.

... ...
@@ -310,6 +310,8 @@ class UptGui:
310 310
         add_list('environment', sorted(proc.environ))
311 311
         add('executable', proc.exe)
312 312
         add('max. resident memory', kb2str(proc.max_rss_kb))
313
+        add('pid', str(proc.pid))
314
+        add('ppid', str(proc.ppid))
313 315
         add('system CPU time', duration2str(proc.sys_time))
314 316
         add('user CPU time', duration2str(proc.user_time))
315 317
         add('working directory', proc.cwd)
... ...
@@ -104,18 +104,38 @@ class Process():
104 104
         return self._end.max_rss_kb
105 105
 
106 106
     @property
107
-    def proc_id(self):
107
+    def parent(self):
108 108
         """
109
-        Process ID. (This is not the PID.)
109
+        Parent process (or None).
110 110
         """
111
-        return self._proc_id
111
+        return self._parent
112 112
 
113 113
     @property
114
-    def parent(self):
114
+    def pid(self):
115 115
         """
116
-        Parent process (or None).
116
+        Linux process ID.
117 117
         """
118
-        return self._parent
118
+        if self._begin is not None:
119
+            return self._begin.pid
120
+        if self._end is not None:
121
+            return self._end.pid
122
+        return None
123
+
124
+    @property
125
+    def ppid(self):
126
+        """
127
+        Linux process ID of parent process.
128
+        """
129
+        if self._begin is None:
130
+            return None
131
+        return self._begin.ppid
132
+
133
+    @property
134
+    def proc_id(self):
135
+        """
136
+        Process ID. (This is not the PID.)
137
+        """
138
+        return self._proc_id
119 139
 
120 140
     @property
121 141
     def sys_time(self) -> float:
122 142