Skip to content

Commit

Permalink
Use provider to get pids
Browse files Browse the repository at this point in the history
  • Loading branch information
stsdc committed Dec 11, 2023
1 parent bb35702 commit d673254
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/Managers/Process.vala
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public class Monitor.Process : GLib.Object {
}

private bool get_children_pids () {
string ? children_content = ProcessUtils.read_file ("/tmp/fakeproc/proc/%d/task/%d/children".printf (stat.pid, stat.pid));
string ? children_content = ProcessUtils.read_file ("/proc/%d/task/%d/children".printf (stat.pid, stat.pid));
if (children_content == "" || children_content == null) {
return false;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ public class Monitor.Process : GLib.Object {

// Reads the /proc/%pid%/stat file and updates the process with the information therein.
private bool parse_stat () {
string ? stat_contents = ProcessUtils.read_file ("/tmp/fakeproc/proc/%d/stat".printf (stat.pid));
string ? stat_contents = ProcessUtils.read_file ("/proc/%d/stat".printf (stat.pid));

if (stat_contents == null) {
return false;
Expand Down Expand Up @@ -282,7 +282,7 @@ public class Monitor.Process : GLib.Object {
* Reads the /proc/%pid%/cmdline file and updates from the information contained therein.
*/
private bool read_cmdline () {
string ? cmdline = ProcessUtils.read_file ("/tmp/fakeproc/proc/%d/cmdline".printf (stat.pid));
string ? cmdline = ProcessUtils.read_file ("/proc/%d/cmdline".printf (stat.pid));

if (cmdline == null) {
return false;
Expand Down
23 changes: 0 additions & 23 deletions src/Managers/ProcessFlatpak.vala

This file was deleted.

10 changes: 3 additions & 7 deletions src/Managers/ProcessManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,10 @@ namespace Monitor {
remove_process (pid);
}

var uid = Posix.getuid ();
GTop.ProcList proclist;
// var pids = GTop.get_proclist (out proclist, GTop.GLIBTOP_KERN_PROC_UID, uid);
var pids = GTop.get_proclist (out proclist, GTop.GLIBTOP_KERN_PROC_ALL, uid);

for (int i = 0; i < proclist.number; i++) {
int pid = pids[i];
var process_provider = ProcessProvider.get_default ();
var pids = process_provider.get_pids ();

foreach (int pid in pids) {
if (!process_list.has_key (pid) && !kernel_process_blacklist.contains (pid)) {
add_process (pid);
}
Expand Down
5 changes: 3 additions & 2 deletions src/Managers/ProcessProvider.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ namespace Monitor {
// }
GTop.ProcList proclist;
// var pids = GTop.get_proclist (out proclist, GTop.GLIBTOP_KERN_PROC_UID, uid);
int[] pids = GTop.get_proclist (out proclist, GTop.GLIBTOP_KERN_PROC_ALL, Posix.getuid ());
debug("%d", pids.length);
var pids = GTop.get_proclist (out proclist, GTop.GLIBTOP_KERN_PROC_ALL, Posix.getuid ());
pids.length = (int) proclist.number;

return pids;
}

Expand Down
1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ source_app_files = [
# 'Managers/AppManager.vala',
'Managers/ProcessManager.vala',
'Managers/Process.vala',
'Managers/ProcessFlatpak.vala',
'Managers/ProcessStructs.vala',
'Managers/ProcessUtils.vala',
'Managers/HttpClientAsync.vala',
Expand Down
2 changes: 1 addition & 1 deletion subprojects/stylesheet
Submodule stylesheet updated 1 files
+10 −12 po/ru.po

0 comments on commit d673254

Please sign in to comment.