Set Task name from p_comm field, and cmdline from KERN_PROC_ARGV
This commit is contained in:
@@ -76,11 +76,9 @@ gboolean get_task_list (GArray *task_list)
|
|||||||
t.vsz *= getpagesize();
|
t.vsz *= getpagesize();
|
||||||
t.rss = p.p_vm_rssize * getpagesize();
|
t.rss = p.p_vm_rssize * getpagesize();
|
||||||
g_snprintf(t.state, sizeof t.state, "%s", state_abbrev[p.p_stat]);
|
g_snprintf(t.state, sizeof t.state, "%s", state_abbrev[p.p_stat]);
|
||||||
|
g_strlcpy(t.name, p.p_comm, strlen(p.p_comm) + 1);
|
||||||
/* shamelessly stolen from top/machine.c */
|
/* shamelessly stolen from top/machine.c */
|
||||||
/* short version: g_strlcpy(t.name, p.p_comm, strlen(p.p_comm) + 1); */
|
if (!P_ZOMBIE(&p)) {
|
||||||
if (P_ZOMBIE(&p)) {
|
|
||||||
g_strlcpy(t.name, p.p_comm, strlen(p.p_comm) + 1);
|
|
||||||
} else {
|
|
||||||
size = 128;
|
size = 128;
|
||||||
if ((args = malloc(size)) == NULL)
|
if ((args = malloc(size)) == NULL)
|
||||||
errx(1,"failed to allocate memory for argv structures");
|
errx(1,"failed to allocate memory for argv structures");
|
||||||
@@ -101,9 +99,7 @@ gboolean get_task_list (GArray *task_list)
|
|||||||
strlcat(buf, *ptr, sizeof(buf));
|
strlcat(buf, *ptr, sizeof(buf));
|
||||||
}
|
}
|
||||||
free(args);
|
free(args);
|
||||||
/* TODO: set difference */
|
g_snprintf(t.cmdline, sizeof t.cmdline, "%s", buf);
|
||||||
g_snprintf(t.name, sizeof t.name, "%s", buf);
|
|
||||||
g_strlcpy(t.cmdline, t.name, sizeof t.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t.cpu_user = (100.0 * ((double) p.p_pctcpu / FSCALE));
|
t.cpu_user = (100.0 * ((double) p.p_pctcpu / FSCALE));
|
||||||
|
|||||||
Reference in New Issue
Block a user