[BACK]Return to top.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / top

Diff for /src/usr.bin/top/top.c between version 1.34 and 1.35

version 1.34, 2004/09/14 22:55:48 version 1.35, 2004/10/07 06:26:12
Line 40 
Line 40 
 #include <string.h>  #include <string.h>
 #include <poll.h>  #include <poll.h>
 #include <stdlib.h>  #include <stdlib.h>
   #include <limits.h>
 #include <unistd.h>  #include <unistd.h>
   
 /* includes specific to top */  /* includes specific to top */
Line 94 
Line 95 
 char *order_name = NULL;  char *order_name = NULL;
 int topn = Default_TOPN;  int topn = Default_TOPN;
 int no_command = Yes;  int no_command = Yes;
   int old_system = No;
   
 #if Default_TOPN == Infinity  #if Default_TOPN == Infinity
 char topn_specified = No;  char topn_specified = No;
Line 121 
Line 123 
 #define CMD_user        14  #define CMD_user        14
 #define CMD_system      15  #define CMD_system      15
 #define CMD_order       16  #define CMD_order       16
   #define CMD_pid         17
   
 static void  static void
 usage(void)  usage(void)
Line 128 
Line 131 
         extern char *__progname;          extern char *__progname;
   
         fprintf(stderr,          fprintf(stderr,
             "usage: %s [-biInqSu] [-d count] [-o field] [-s time] [-U username] [number]\n",              "usage: %s [-biInqSu] [-d count] [-o field] [-p pid] [-s time] [-U username] [number]\n",
             __progname);              __progname);
 }  }
   
Line 138 
Line 141 
         char *endp;          char *endp;
         int i;          int i;
   
         while ((i = getopt(ac, av, "SIbinqus:d:U:o:")) != -1) {          while ((i = getopt(ac, av, "SIbinqus:d:p:U:o:")) != -1) {
                 switch (i) {                  switch (i) {
                 case 'u':       /* toggle uid/username display */                  case 'u':       /* toggle uid/username display */
                         do_unames = !do_unames;                          do_unames = !do_unames;
Line 151 
Line 154 
                         }                          }
                         break;                          break;
   
                   case 'p': {     /* display only process id */
                           unsigned long long num;
                           const char *errstr;
   
                           num = strtonum(optarg, 0, INT_MAX, &errstr);
                           if (errstr != NULL || !find_pid(num)) {
                                   fprintf(stderr, "%s: unknown pid\n", optarg);
                                   exit(1);
                           }
                           ps.pid = (pid_t)num;
                           ps.system = Yes;
                           break;
                   }
   
                 case 'S':       /* show system processes */                  case 'S':       /* show system processes */
                         ps.system = !ps.system;                          ps.system = Yes;
                           old_system = Yes;
                         break;                          break;
   
                 case 'I':       /* show idle processes */                  case 'I':       /* show idle processes */
Line 249 
Line 267 
         ps.idle = Yes;          ps.idle = Yes;
         ps.system = No;          ps.system = No;
         ps.uid = (uid_t)-1;          ps.uid = (uid_t)-1;
           ps.pid = (pid_t)-1;
         ps.command = NULL;          ps.command = NULL;
   
         /* get preset options from the environment */          /* get preset options from the environment */
Line 492 
Line 511 
         int change, i;          int change, i;
         struct pollfd pfd[1];          struct pollfd pfd[1];
         uid_t uid;          uid_t uid;
         static char command_chars[] = "\f qh?en#sdkriIuSo";          static char command_chars[] = "\f qh?en#sdkriIuSop";
   
         /*          /*
          * assume valid command unless told           * assume valid command unless told
Line 772 
Line 791 
   
                 case CMD_system:                  case CMD_system:
                         ps.system = !ps.system;                          ps.system = !ps.system;
                           old_system = ps.system;
                         new_message(MT_standout | MT_delayed,                          new_message(MT_standout | MT_delayed,
                             " %sisplaying system processes.",                              " %sisplaying system processes.",
                             ps.system ? "D" : "Not d");                              ps.system ? "D" : "Not d");
Line 790 
Line 810 
                                         no_command = Yes;                                          no_command = Yes;
                                 } else                                  } else
                                         order_index = i;                                          order_index = i;
                                   if (putchar('\r') == EOF)
                                           exit(1);
                           } else
                                   clear_message();
                           break;
   
                   case CMD_pid:
                           new_message(MT_standout, "Process id to show: ");
                           if (readline(tempbuf2, sizeof(tempbuf2), No) > 0) {
                                   if (tempbuf2[0] == '+' &&
                                       tempbuf2[1] == '\0') {
                                           ps.pid = (pid_t)-1;
                                           ps.system = old_system;
                                   } else {
                                           unsigned long long num;
                                           const char *errstr;
   
                                           num = strtonum(tempbuf2, 0, INT_MAX,
                                               &errstr);
                                           if (errstr != NULL || !find_pid(num)) {
                                                   new_message(MT_standout,
                                                       " %s: unknown pid",
                                                       tempbuf2);
                                                   no_command = Yes;
                                           } else {
                                                   if (ps.system == No)
                                                           old_system = No;
                                                   ps.pid = (pid_t)num;
                                                   ps.system = Yes;
                                           }
                                   }
                                 if (putchar('\r') == EOF)                                  if (putchar('\r') == EOF)
                                         exit(1);                                          exit(1);
                         } else                          } else

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35