Procházet zdrojové kódy

SystemMonitor: Show PPID, PGID, SID

With this information, it's a bit easier to intuit the current 'process tree'.
If you're reading this, can I convince you to implement a nice process tree for
SystemMonitor? It could be via PPID (unbounded depth), or SID+PGID (depth 3).
Or something else entirely :D
Ben Wiederhake před 5 roky
rodič
revize
81b491a7a4

+ 24 - 0
Applications/SystemMonitor/ProcessModel.cpp

@@ -90,6 +90,12 @@ String ProcessModel::column_name(int column) const
         return "PID";
     case Column::TID:
         return "TID";
+    case Column::PPID:
+        return "PPID";
+    case Column::PGID:
+        return "PGID";
+    case Column::SID:
+        return "SID";
     case Column::State:
         return "State";
     case Column::User:
@@ -165,6 +171,9 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, Role role) const
             return Gfx::TextAlignment::CenterLeft;
         case Column::PID:
         case Column::TID:
+        case Column::PPID:
+        case Column::PGID:
+        case Column::SID:
         case Column::Priority:
         case Column::EffectivePriority:
         case Column::Virtual:
@@ -202,6 +211,12 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, Role role) const
             return thread.current_state.pid;
         case Column::TID:
             return thread.current_state.tid;
+        case Column::PPID:
+            return thread.current_state.ppid;
+        case Column::PGID:
+            return thread.current_state.pgid;
+        case Column::SID:
+            return thread.current_state.sid;
         case Column::State:
             return thread.current_state.state;
         case Column::User:
@@ -273,6 +288,12 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, Role role) const
             return thread.current_state.pid;
         case Column::TID:
             return thread.current_state.tid;
+        case Column::PPID:
+            return thread.current_state.ppid;
+        case Column::PGID:
+            return thread.current_state.pgid;
+        case Column::SID:
+            return thread.current_state.sid;
         case Column::State:
             return thread.current_state.state;
         case Column::User:
@@ -366,7 +387,10 @@ void ProcessModel::update()
 
             state.name = thread.name;
 
+            state.ppid = it.value.ppid;
             state.tid = thread.tid;
+            state.pgid = it.value.pgid;
+            state.sid = it.value.sid;
             state.times_scheduled = thread.times_scheduled;
             state.cpu = thread.cpu;
             state.priority = thread.priority;

+ 7 - 1
Applications/SystemMonitor/ProcessModel.h

@@ -57,6 +57,9 @@ public:
         User,
         PID,
         TID,
+        PPID,
+        PGID,
+        SID,
         Virtual,
         Physical,
         DirtyPrivate,
@@ -107,8 +110,11 @@ private:
     ProcessModel();
 
     struct ThreadState {
-        int tid;
+        pid_t tid;
         pid_t pid;
+        pid_t ppid;
+        pid_t pgid;
+        pid_t sid;
         unsigned times_scheduled;
         String name;
         String state;