H m -m -L -T are all working
This commit is contained in:
parent
7dfe80961a
commit
e583724fff
@ -666,7 +666,7 @@ static int simple_nexttid(PROCTAB *restrict const PT, const proc_t *restrict con
|
|||||||
closedir(PT->taskdir);
|
closedir(PT->taskdir);
|
||||||
}
|
}
|
||||||
// use "path" as some tmp space
|
// use "path" as some tmp space
|
||||||
snprintf(path, PROCPATHLEN, "%s/task", PT->path);
|
snprintf(path, PROCPATHLEN, "/proc/%d/task", p->tgid);
|
||||||
PT->taskdir = opendir(path);
|
PT->taskdir = opendir(path);
|
||||||
if(!PT->taskdir) return 0;
|
if(!PT->taskdir) return 0;
|
||||||
PT->taskdir_user = p->tgid;
|
PT->taskdir_user = p->tgid;
|
||||||
@ -679,7 +679,7 @@ static int simple_nexttid(PROCTAB *restrict const PT, const proc_t *restrict con
|
|||||||
t->tid = strtoul(ent->d_name, NULL, 10);
|
t->tid = strtoul(ent->d_name, NULL, 10);
|
||||||
t->tgid = p->tgid;
|
t->tgid = p->tgid;
|
||||||
t->ppid = p->ppid; // cover for kernel behavior? we want both actually...?
|
t->ppid = p->ppid; // cover for kernel behavior? we want both actually...?
|
||||||
snprintf(path, PROCPATHLEN, "%s/task/%s", PT->path, ent->d_name);
|
snprintf(path, PROCPATHLEN, "/proc/%d/task/%s", p->tgid, ent->d_name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
48
ps/display.c
48
ps/display.c
@ -330,19 +330,51 @@ static void simple_spew(void){
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
memset(&buf, '#', sizeof(proc_t));
|
memset(&buf, '#', sizeof(proc_t));
|
||||||
while(readproc(ptp,&buf)){
|
switch(thread_flags & (TF_show_proc|TF_loose_tasks|TF_show_task)){
|
||||||
if(want_this_proc(&buf)){
|
case TF_show_proc: // normal non-thread output
|
||||||
if(thread_flags & TF_show_proc) show_one_proc(&buf, proc_format_list);
|
while(readproc(ptp,&buf)){
|
||||||
if(thread_flags & TF_show_task){
|
if(want_this_proc(&buf)){
|
||||||
|
show_one_proc(&buf, proc_format_list);
|
||||||
|
}
|
||||||
|
if(buf.cmdline) free((void*)*buf.cmdline); // ought to reuse
|
||||||
|
if(buf.environ) free((void*)*buf.environ); // ought to reuse
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TF_show_proc|TF_loose_tasks: // H option
|
||||||
|
while(readproc(ptp,&buf)){
|
||||||
|
proc_t buf2;
|
||||||
|
// must still have the process allocated
|
||||||
|
while(readtask(ptp,&buf,&buf2)){
|
||||||
|
if(!want_this_proc(&buf)) continue;
|
||||||
|
show_one_proc(&buf2, task_format_list);
|
||||||
|
}
|
||||||
|
if(buf.cmdline) free((void*)*buf.cmdline); // ought to reuse
|
||||||
|
if(buf.environ) free((void*)*buf.environ); // ought to reuse
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TF_show_proc|TF_show_task: // m and -m options
|
||||||
|
while(readproc(ptp,&buf)){
|
||||||
|
if(want_this_proc(&buf)){
|
||||||
|
proc_t buf2;
|
||||||
|
show_one_proc(&buf, proc_format_list);
|
||||||
|
// must still have the process allocated
|
||||||
|
while(readtask(ptp,&buf,&buf2)) show_one_proc(&buf2, task_format_list);
|
||||||
|
}
|
||||||
|
if(buf.cmdline) free((void*)*buf.cmdline); // ought to reuse
|
||||||
|
if(buf.environ) free((void*)*buf.environ); // ought to reuse
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TF_show_task: // -L and -T options
|
||||||
|
while(readproc(ptp,&buf)){
|
||||||
|
if(want_this_proc(&buf)){
|
||||||
proc_t buf2;
|
proc_t buf2;
|
||||||
// must still have the process allocated
|
// must still have the process allocated
|
||||||
while(readtask(ptp,&buf,&buf2)) show_one_proc(&buf2, task_format_list);
|
while(readtask(ptp,&buf,&buf2)) show_one_proc(&buf2, task_format_list);
|
||||||
// must not attempt to free cmdline and environ
|
|
||||||
}
|
}
|
||||||
|
if(buf.cmdline) free((void*)*buf.cmdline); // ought to reuse
|
||||||
|
if(buf.environ) free((void*)*buf.environ); // ought to reuse
|
||||||
}
|
}
|
||||||
if(buf.cmdline) free((void*)*buf.cmdline); // ought to reuse
|
break;
|
||||||
if(buf.environ) free((void*)*buf.environ); // ought to reuse
|
|
||||||
// memset(&buf, '#', sizeof(proc_t));
|
|
||||||
}
|
}
|
||||||
closeproc(ptp);
|
closeproc(ptp);
|
||||||
}
|
}
|
||||||
|
4
top.c
4
top.c
@ -33,7 +33,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
// Foul POS defines all sorts of stuff...
|
||||||
#include <term.h>
|
#include <term.h>
|
||||||
|
#undef tab
|
||||||
|
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user