[gnome-usage] Changed Posix.pid_t to GLib.Pid.
- From: Petr Štětka <pstetka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-usage] Changed Posix.pid_t to GLib.Pid.
- Date: Mon, 13 Mar 2017 11:13:32 +0000 (UTC)
commit aa28feed61a99047615c638071dd74efd010a4a1
Author: Petr Štětka <pstetka redhat com>
Date: Mon Mar 13 12:13:13 2017 +0100
Changed Posix.pid_t to GLib.Pid.
src/cpu-monitor.vala | 2 -
src/memory-monitor.vala | 2 -
src/network-monitor.vala | 1 -
src/process-dialog.vala | 10 ++++----
src/process-row.vala | 1 -
src/process.vala | 16 ++++++--------
src/sub-process-list-box.vala | 1 -
src/sub-process-sub-row.vala | 2 -
src/system-monitor.vala | 44 ++++++++--------------------------------
src/vapis/glibtop.vapi | 26 ++++++++++++++++++-----
10 files changed, 41 insertions(+), 64 deletions(-)
---
diff --git a/src/cpu-monitor.vala b/src/cpu-monitor.vala
index 4e75b17..53e46e7 100644
--- a/src/cpu-monitor.vala
+++ b/src/cpu-monitor.vala
@@ -1,5 +1,3 @@
-using Posix;
-
namespace Usage
{
public class CpuMonitor
diff --git a/src/memory-monitor.vala b/src/memory-monitor.vala
index 81ee604..d59783f 100644
--- a/src/memory-monitor.vala
+++ b/src/memory-monitor.vala
@@ -1,5 +1,3 @@
-using Posix;
-
namespace Usage
{
public class MemoryMonitor
diff --git a/src/network-monitor.vala b/src/network-monitor.vala
index 1a88f54..ddad2c2 100644
--- a/src/network-monitor.vala
+++ b/src/network-monitor.vala
@@ -1,5 +1,4 @@
using NI;
-using Posix;
namespace Usage
{
diff --git a/src/process-dialog.vala b/src/process-dialog.vala
index 432362f..59349a0 100644
--- a/src/process-dialog.vala
+++ b/src/process-dialog.vala
@@ -5,7 +5,7 @@ namespace Usage
public class ProcessDialog : Gtk.Dialog
{
ProcessDialogHeaderBar headerbar;
- pid_t pid;
+ Pid pid;
string process;
GraphBlock processor_graph_block;
GraphBlock memory_graph_block;
@@ -13,7 +13,7 @@ namespace Usage
GraphBlock downloads_graph_block;
GraphBlock uploads_graph_block;
- public ProcessDialog(pid_t pid, string app_name, string process)
+ public ProcessDialog(Pid pid, string app_name, string process)
{
Object(use_header_bar: 1);
set_modal(true);
@@ -101,7 +101,7 @@ namespace Usage
private string process;
private Gtk.Button stop_button;
- public ProcessDialogHeaderBar(Gtk.Button stop_button, pid_t pid, string app_name, string process)
+ public ProcessDialogHeaderBar(Gtk.Button stop_button, Pid pid, string app_name, string process)
{
this.app_name = app_name;
this.process = process;
@@ -133,9 +133,9 @@ namespace Usage
return !(process in unkillable_processes);
}
- private void kill_process(pid_t pid)
+ private void kill_process(Pid pid)
{
- Posix.kill (pid, Posix.SIGKILL);
+ Posix.kill (pid, Posix.SIGKILL);
}
public void set_process_state(ProcessStatus status)
diff --git a/src/process-row.vala b/src/process-row.vala
index bc5299b..b45b359 100644
--- a/src/process-row.vala
+++ b/src/process-row.vala
@@ -1,4 +1,3 @@
-using Posix;
using Gee;
namespace Usage
diff --git a/src/process.vala b/src/process.vala
index 0b94343..8a14eee 100644
--- a/src/process.vala
+++ b/src/process.vala
@@ -1,10 +1,8 @@
-using Posix;
-
namespace Usage
{
public class Process : Object
{
- pid_t pid;
+ Pid pid;
string cmdline;
string cmdline_parameter; //Isn't parameters as "-p" etc, but parameter for running app, for ex.
"--writer' with libreoffice, or "privacy" with gnome-control-center
string display_name;
@@ -17,11 +15,11 @@ namespace Usage
uint64 net_download;
uint64 net_upload;
uint64 net_all;
- HashTable<pid_t?, Process>? sub_processes;
+ HashTable<Pid?, Process>? sub_processes;
bool alive;
ProcessStatus status;
- public Process(pid_t pid, string cmdline, string cmdline_parameter, string display_name)
+ public Process(Pid pid, string cmdline, string cmdline_parameter, string display_name)
{
this.pid = pid;
this.cmdline = cmdline;
@@ -56,12 +54,12 @@ namespace Usage
this.status = process.get_status();
}
- public pid_t get_pid()
+ public Pid get_pid()
{
return pid;
}
- public void set_pid(pid_t pid)
+ public void set_pid(Pid pid)
{
this.pid = pid;
}
@@ -186,12 +184,12 @@ namespace Usage
this.net_all = net_all;
}
- public HashTable<pid_t?, Process>? get_sub_processes()
+ public HashTable<Pid?, Process>? get_sub_processes()
{
return sub_processes;
}
- public void set_sub_processes(HashTable<pid_t?, Process>? sub_processes)
+ public void set_sub_processes(HashTable<Pid?, Process>? sub_processes)
{
this.sub_processes = sub_processes;
}
diff --git a/src/sub-process-list-box.vala b/src/sub-process-list-box.vala
index d9bd1f8..24ffbfe 100644
--- a/src/sub-process-list-box.vala
+++ b/src/sub-process-list-box.vala
@@ -1,5 +1,4 @@
using Gee;
-using Posix;
namespace Usage
{
diff --git a/src/sub-process-sub-row.vala b/src/sub-process-sub-row.vala
index c1d77a9..b3ab960 100644
--- a/src/sub-process-sub-row.vala
+++ b/src/sub-process-sub-row.vala
@@ -1,5 +1,3 @@
-using Posix;
-
namespace Usage
{
public class SubProcessSubRow : Gtk.ListBoxRow
diff --git a/src/system-monitor.vala b/src/system-monitor.vala
index 46b80ff..ca15c9f 100644
--- a/src/system-monitor.vala
+++ b/src/system-monitor.vala
@@ -1,5 +1,3 @@
-using Posix;
-
namespace Usage
{
public class SystemMonitor : Object
@@ -19,27 +17,20 @@ namespace Usage
private MemoryMonitor memory_monitor;
private NetworkMonitor network_monitor;
- private HashTable<pid_t?, Process> process_table_pid;
+ private HashTable<Pid?, Process> process_table_pid;
private HashTable<string, Process> cpu_process_table;
private HashTable<string, Process> ram_process_table;
private HashTable<string, Process> net_process_table;
- private int process_mode = GTop.KERN_PROC_UID;
+ private int process_mode = GTop.EXCLUDE_SYSTEM;
private GLib.List<AppInfo> apps_info;
- public enum ProcessMode
- {
- ALL,
- USER,
- EXCLUDE_IDLE
- }
-
public List<unowned Process> get_processes_pid()
{
return process_table_pid.get_values();
}
- public unowned Process get_process_by_pid(pid_t pid)
+ public unowned Process get_process_by_pid(Pid pid)
{
return process_table_pid.get(pid);
}
@@ -87,7 +78,7 @@ namespace Usage
memory_monitor = new MemoryMonitor();
network_monitor = new NetworkMonitor();
- process_table_pid = new HashTable<pid_t?, Process>(int_hash, int_equal);
+ process_table_pid = new HashTable<Pid?, Process>(int_hash, int_equal);
cpu_process_table = new HashTable<string, Process>(str_hash, str_equal);
ram_process_table = new HashTable<string, Process>(str_hash, str_equal);
net_process_table = new HashTable<string, Process>(str_hash, str_equal);
@@ -129,9 +120,8 @@ namespace Usage
set_alive_false_table_cmdline(ref ram_process_table);
set_alive_false_table_cmdline(ref net_process_table);
- var uid = Posix.getuid();
GTop.Proclist proclist;
- var pids = GTop.get_proclist (out proclist, process_mode, uid);
+ var pids = GTop.get_proclist (out proclist, process_mode);
for(uint i = 0; i < proclist.number; i++)
{
@@ -164,7 +154,7 @@ namespace Usage
}
}
- var process_table_pid_condition = new HashTable<pid_t?, Process>(int_hash, int_equal);
+ var process_table_pid_condition = new HashTable<Pid?, Process>(int_hash, int_equal);
foreach(unowned Process process in process_table_pid.get_values())
{
if(process.get_cpu_load() >= 1)
@@ -191,22 +181,6 @@ namespace Usage
return true;
}
- public void set_process_mode(ProcessMode mode)
- {
- switch(mode)
- {
- case ProcessMode.ALL:
- process_mode = GTop.KERN_PROC_ALL;
- break;
- case ProcessMode.USER:
- process_mode = GTop.KERN_PROC_UID;
- break;
- case ProcessMode.EXCLUDE_IDLE:
- process_mode = GTop.EXCLUDE_IDLE;
- break;
- }
- }
-
private string get_display_name(string cmdline, string cmdline_parameter)
{
AppInfo app_info = null;
@@ -250,7 +224,7 @@ namespace Usage
return cmdline;
}
- private string get_full_process_cmd_for_pid (pid_t pid, out string cmd_parameter)
+ private string get_full_process_cmd_for_pid (Pid pid, out string cmd_parameter)
{
GTop.ProcArgs proc_args;
GTop.ProcState proc_state;
@@ -342,7 +316,7 @@ namespace Usage
}
}
- private void get_updates_table_cmdline(HashTable<pid_t?, Process> from_table, ref HashTable<string,
Process> to_table)
+ private void get_updates_table_cmdline(HashTable<Pid?, Process> from_table, ref HashTable<string,
Process> to_table)
{
foreach(unowned Process process_it in from_table.get_values())
{
@@ -371,7 +345,7 @@ namespace Usage
}
else //transform to group and add subrow
{
- to_table[process_it.get_cmdline()].set_sub_processes(new HashTable<pid_t?,
Process>(int_hash, int_equal));
+ to_table[process_it.get_cmdline()].set_sub_processes(new HashTable<Pid?,
Process>(int_hash, int_equal));
unowned Process process = to_table[process_it.get_cmdline()];
var sub_process_one = new Process(process.get_pid(), process.get_cmdline(),
process.get_cmdline_parameter(), process.get_display_name());
diff --git a/src/vapis/glibtop.vapi b/src/vapis/glibtop.vapi
index b55250e..d5b1bc0 100644
--- a/src/vapis/glibtop.vapi
+++ b/src/vapis/glibtop.vapi
@@ -29,10 +29,24 @@ namespace GTop {
[CCode(cname = "GLIBTOP_KERN_PROC_ALL")]
public const int KERN_PROC_ALL;
+ [CCode(cname = "GLIBTOP_KERN_PROC_PID")]
+ public const int KERN_PROC_PID;
+ [CCode(cname = "GLIBTOP_KERN_PROC_PGRP")]
+ public const int KERN_PROC_PRGP;
+ [CCode(cname = "GLIBTOP_KERN_PROC_SESSION")]
+ public const int KERN_PROC_SESSION;
+ [CCode(cname = "GLIBTOP_KERN_PROC_TTY")]
+ public const int KERN_PROC_TTY;
[CCode(cname = "GLIBTOP_KERN_PROC_UID")]
public const int KERN_PROC_UID;
+ [CCode(cname = "GLIBTOP_KERN_PROC_RUID")]
+ public const int KERN_PROC_RUID;
+ [CCode(cname = "GLIBTOP_KERN_PROC_MASK")]
+ public const int KERN_PROC_MASK;
[CCode(cname = "GLIBTOP_EXCLUDE_IDLE")]
public const int EXCLUDE_IDLE;
+ [CCode(cname = "GLIBTOP_EXCLUDE_SYSTEM")]
+ public const int EXCLUDE_SYSTEM;
[CCode(cname = "glibtop_proclist", cheader_filename = "glibtop/proclist.h")]
public struct Proclist {
@@ -42,7 +56,7 @@ namespace GTop {
uint64 size;
}
[CCode(array_length = false, array_null_terminated = false)]
- public Posix.pid_t[] get_proclist(out Proclist proclist, uint64 which, uint64 arg);
+ public GLib.Pid[] get_proclist(out Proclist proclist, uint64 which, uint64? arg = null);
[CCode(cname = "glibtop_proc_state", cheader_filename = "glibtop/procstate.h")]
public struct ProcState {
@@ -57,7 +71,7 @@ namespace GTop {
int processor;
int last_processor;
}
- public void get_proc_state(out ProcState proc_state, Posix.pid_t pid);
+ public void get_proc_state(out ProcState proc_state, GLib.Pid pid);
[CCode(cname = "GLIBTOP_PROCESS_RUNNING")]
public const int PROCESS_RUNNING;
@@ -89,7 +103,7 @@ namespace GTop {
uint64 xcpu_utime[1024];
uint64 xcpu_stime[1024];
}
- public void get_proc_time(out ProcTime proc_time, Posix.pid_t pid);
+ public void get_proc_time(out ProcTime proc_time, GLib.Pid pid);
[CCode(cname = "glibtop_mem", cheader_filename = "glibtop/mem.h")]
public struct Mem {
@@ -126,7 +140,7 @@ namespace GTop {
uint64 rss;
uint64 rss_rlim;
}
- public void get_proc_mem(out ProcMem proc_mem, Posix.pid_t pid);
+ public void get_proc_mem(out ProcMem proc_mem, GLib.Pid pid);
[CCode(cname = "glibtop_netlist", cheader_filename = "glibtop/netlist.h")]
public struct Netlist {
@@ -159,7 +173,7 @@ namespace GTop {
int32 ngroups;
int32 groups[64];
}
- public void get_proc_uid(out ProcUid proc_uid, Posix.pid_t pid);
+ public void get_proc_uid(out ProcUid proc_uid, GLib.Pid pid);
[CCode(cname = "glibtop_proc_args", cheader_filename = "glibtop/procargs.h")]
public struct ProcArgs {
@@ -167,7 +181,7 @@ namespace GTop {
uint64 size;
}
[CCode(array_null_terminated = "true")]
- public string[] get_proc_argv(out ProcArgs proc_args, Posix.pid_t pid);
+ public string[] get_proc_argv(out ProcArgs proc_args, GLib.Pid pid);
[CCode(cname = "glibtop_fsusage", cheader_filename = "glibtop/fsusage.h")]
public struct FsUsage {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]