]> granicus.if.org Git - procps-ng/commitdiff
"top -p1" then hit "=" did SIGSEGV; flags not regenerated right
authoralbert <>
Wed, 28 Jan 2004 21:53:44 +0000 (21:53 +0000)
committeralbert <>
Wed, 28 Jan 2004 21:53:44 +0000 (21:53 +0000)
NEWS
pmap.c
ps/display.c
top.c

diff --git a/NEWS b/NEWS
index 7c70a745de789d76fde1adf0db41e59d6a29dde0..9cf4364850977311751db04a036b81646a5969e7 100644 (file)
--- a/NEWS
+++ b/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
 
diff --git a/pmap.c b/pmap.c
index 38a60d396566b67752e1619747fc52eb4c011c23..32462d69ddcf87ec25478d1ec94f83e78d5edb12 100644 (file)
--- a/pmap.c
+++ b/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++;
index a52769b4837ea7a5828fcd04be6b6349b5f9cae0..d313c27314987843eb3630e33c073d115a2917e1 100644 (file)
@@ -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);
diff --git a/top.c b/top.c
index 2446d04ec50a2c38d7e79cc175e1514344fa42c2..bbf23a92388cbc609080aa898a7c760d506bfb73 100644 (file)
--- a/top.c
+++ b/top.c
@@ -2718,6 +2718,7 @@ static void do_key (unsigned c)
          Curwin->rc.maxtasks = 0;
          SETw(Curwin, Show_IDLEPS | VISIBLE_tsk);
          Monpidsidx = 0;
+         selection_type = '\0';
          break;
 
       case '+':