+/- debug code
This commit is contained in:
parent
e96d6b6141
commit
9736b7be92
24
ps/display.c
24
ps/display.c
@ -228,14 +228,14 @@ static void simple_spew(void){
|
|||||||
fprintf(stderr, "Error: can not access /proc.\n");
|
fprintf(stderr, "Error: can not access /proc.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
/* memset(&buf, '#', sizeof(proc_t)); */
|
memset(&buf, '#', sizeof(proc_t));
|
||||||
/* use "ps_" prefix to catch library mismatch */
|
/* use "ps_" prefix to catch library mismatch */
|
||||||
while(ps_readproc(ptp,&buf)){
|
while(ps_readproc(ptp,&buf)){
|
||||||
fill_pcpu(&buf);
|
fill_pcpu(&buf);
|
||||||
if(want_this_proc(&buf)) show_one_proc(&buf);
|
if(want_this_proc(&buf)) show_one_proc(&buf);
|
||||||
/* if(buf.cmdline) free(buf.cmdline); */ /* these crash */
|
if(buf.cmdline) free((void*)*buf.cmdline); // ought to reuse
|
||||||
/* if(buf.environ) free(buf.environ); */
|
if(buf.environ) free((void*)*buf.environ); // ought to reuse
|
||||||
/* memset(&buf, '#', sizeof(proc_t)); */
|
// memset(&buf, '#', sizeof(proc_t));
|
||||||
}
|
}
|
||||||
closeproc(ptp);
|
closeproc(ptp);
|
||||||
}
|
}
|
||||||
@ -286,10 +286,11 @@ static void show_proc_array(int n){
|
|||||||
proc_t **p = processes;
|
proc_t **p = processes;
|
||||||
while(n--){
|
while(n--){
|
||||||
show_one_proc(*p);
|
show_one_proc(*p);
|
||||||
/* if(p->cmdline) free(p->cmdline); */ /* this crashes */
|
/* no point freeing any of this -- won't need more mem */
|
||||||
/* if(p->environ) free(p->environ); */ /* this crashes */
|
// if((*p)->cmdline) free((void*)*(*p)->cmdline);
|
||||||
/* memset(*p, '%', sizeof(proc_t)); */ /* debug */
|
// if((*p)->environ) free((void*)*(*p)->environ);
|
||||||
free(*p);
|
// memset(*p, '%', sizeof(proc_t)); /* debug */
|
||||||
|
// free(*p);
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,9 +307,9 @@ static void show_tree(const int self, const int n, const int level, const int ha
|
|||||||
forest_prefix[level] = '\0';
|
forest_prefix[level] = '\0';
|
||||||
}
|
}
|
||||||
show_one_proc(processes[self]); /* first show self */
|
show_one_proc(processes[self]); /* first show self */
|
||||||
/* if(p->cmdline) free(p->cmdline); */ /* this crashes */
|
/* no point freeing any of this -- won't need more mem */
|
||||||
/* if(p->environ) free(p->environ); */ /* this crashes */
|
// if(processes[self]->cmdline) free((void*)*processes[self]->cmdline);
|
||||||
/* memset(*p, '%', sizeof(proc_t)); */ /* debug */
|
// if(processes[self]->environ) free((void*)*processes[self]->environ);
|
||||||
for(;;){ /* look for children */
|
for(;;){ /* look for children */
|
||||||
if(i >= n) return; /* no children */
|
if(i >= n) return; /* no children */
|
||||||
if(processes[i]->ppid == processes[self]->pid) break;
|
if(processes[i]->ppid == processes[self]->pid) break;
|
||||||
@ -337,6 +338,7 @@ static void show_tree(const int self, const int n, const int level, const int ha
|
|||||||
}
|
}
|
||||||
/* chop prefix that children added -- do we need this? */
|
/* chop prefix that children added -- do we need this? */
|
||||||
forest_prefix[level] = '\0';
|
forest_prefix[level] = '\0';
|
||||||
|
// memset(processes[self], '$', sizeof(proc_t)); /* debug */
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** show forest */
|
/***** show forest */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user