"top -p1" then hit "=" did SIGSEGV; flags not regenerated right
This commit is contained in:
parent
1e1218cca8
commit
a760a2c22d
1
NEWS
1
NEWS
@ -4,6 +4,7 @@ ps: also handle SELinux on the 2.4.xx kernels
|
||||
top: during a ^Z, the terminal was messed up #228822
|
||||
future-proof the tty handling (thanks to Zhou Wei)
|
||||
slabtop (Chris Rivera and Robert Love) #226778 rh114012a
|
||||
pmap: detect the primary stack
|
||||
|
||||
procps-3.1.14 --> procps-3.1.15
|
||||
|
||||
|
21
pmap.c
21
pmap.c
@ -79,7 +79,9 @@ static const char *get_args(unsigned pid){
|
||||
static const char *anon_name(int pid, unsigned KLONG addr, unsigned KLONG len){
|
||||
const char *cp = " [ anon ]";
|
||||
proc_t proc;
|
||||
if (get_proc_stats(pid, &proc)){
|
||||
static int oldpid = -1;
|
||||
if (pid==oldpid || get_proc_stats(pid, &proc)){
|
||||
oldpid = pid;
|
||||
if( (proc.start_stack >= addr) && (proc.start_stack <= addr+len) ) cp = " [ stack ]";
|
||||
}
|
||||
return cp;
|
||||
@ -111,6 +113,12 @@ static int one_proc(unsigned pid){
|
||||
tmp++;
|
||||
}
|
||||
|
||||
diff = end-start;
|
||||
if(flags[3]=='s') total_shared += diff;
|
||||
if(flags[3]=='p') total_private += diff;
|
||||
|
||||
#if 1
|
||||
// format used by Solaris 7 and old procps
|
||||
if(flags[0]=='r'){
|
||||
if(flags[1]=='w'){
|
||||
if(flags[2]=='x') perms = "read/write/exec";
|
||||
@ -128,9 +136,14 @@ static int one_proc(unsigned pid){
|
||||
else perms = "none ";
|
||||
}
|
||||
}
|
||||
diff = end-start;
|
||||
if(flags[3]=='s') total_shared += diff;
|
||||
if(flags[3]=='p') total_private += diff;
|
||||
#else
|
||||
// format used by Solaris 9 and future procps
|
||||
perms = flags;
|
||||
if(flags[3] == 'p') flags[3] = '-';
|
||||
flags[4] = '-'; // an 'R' if swap not reserved (MAP_NORESERVE, SysV ISM shared mem, etc.)
|
||||
flags[5] = '\0';
|
||||
#endif
|
||||
|
||||
if(x_option){
|
||||
const char *cp = strrchr(mapbuf,'/');
|
||||
if(cp && cp[1]) cp++;
|
||||
|
20
ps/display.c
20
ps/display.c
@ -516,27 +516,13 @@ static void fancy_spew(void){
|
||||
proc_data_t *pd = NULL;
|
||||
PROCTAB *restrict ptp;
|
||||
int n = 0; /* number of processes & index into array */
|
||||
#if 0
|
||||
if(thread_flags){
|
||||
fprintf(stderr, "can't have threads with sorting or forest output\n");
|
||||
exit(49);
|
||||
}
|
||||
#endif
|
||||
|
||||
ptp = openproc(needs_for_format | needs_for_sort | needs_for_select | needs_for_threads);
|
||||
if(!ptp) {
|
||||
fprintf(stderr, "Error: can not access /proc.\n");
|
||||
exit(1);
|
||||
}
|
||||
#if 0
|
||||
while((retbuf = readproc(ptp,retbuf))){
|
||||
if(want_this_proc_pcpu(retbuf)){
|
||||
// fill_pcpu(retbuf); // in case we might sort by %cpu
|
||||
processes[n++] = retbuf;
|
||||
retbuf = NULL; // NULL asks readproc to allocate
|
||||
}
|
||||
}
|
||||
if(retbuf) free(retbuf);
|
||||
#else
|
||||
|
||||
if(thread_flags & TF_loose_tasks){
|
||||
pd = readproctab2(want_this_proc_nop, want_this_proc_pcpu, ptp);
|
||||
}else{
|
||||
@ -544,7 +530,7 @@ static void fancy_spew(void){
|
||||
}
|
||||
n = pd->n;
|
||||
processes = pd->tab;
|
||||
#endif
|
||||
|
||||
if(!n) return; /* no processes */
|
||||
if(forest_type) prep_forest_sort();
|
||||
qsort(processes, n, sizeof(proc_t*), compare_two_procs);
|
||||
|
Loading…
Reference in New Issue
Block a user