[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.91 and 1.92

version 1.91, 2018/09/13 15:23:32 version 1.92, 2018/09/22 16:50:35
Line 36 
Line 36 
 #include <signal.h>  #include <signal.h>
 #include <string.h>  #include <string.h>
 #include <poll.h>  #include <poll.h>
   #include <pwd.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <limits.h>  #include <limits.h>
 #include <unistd.h>  #include <unistd.h>
Line 150 
Line 151 
   
                 case 'U':       /* display only username's processes */                  case 'U':       /* display only username's processes */
                         if (optarg[0] == '-') {                          if (optarg[0] == '-') {
                                 if ((ps.huid = userid(optarg+1)) == (uid_t)-1)                                  if (uid_from_user(optarg+1, &ps.huid) == -1)
                                         new_message(MT_delayed, "%s: unknown user",                                          new_message(MT_delayed,
                                             optarg);                                              "%s: unknown user", optarg);
                                 else                                  else
                                         ps.uid = (uid_t)-1;                                          ps.uid = (uid_t)-1;
                         } else if ((ps.uid = userid(optarg)) == (uid_t)-1)                          } else if (uid_from_user(optarg, &ps.uid) == -1)
                                 new_message(MT_delayed, "%s: unknown user",                                  new_message(MT_delayed, "%s: unknown user",
                                     optarg);                                      optarg);
                         else                          else
Line 279 
Line 280 
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
         char *uname_field = "USERNAME", *header_text, *env_top;          char *uname_field = "USERNAME", *header_text, *env_top;
         const char *(*get_userid)(uid_t) = username;          const char *(*get_userid)(uid_t, int) = user_from_uid;
         char **preset_argv = NULL, **av = argv;          char **preset_argv = NULL, **av = argv;
         int preset_argc = 0, ac = argc, active_procs, i;          int preset_argc = 0, ac = argc, active_procs, i;
         sigset_t mask, oldmask;          sigset_t mask, oldmask;
Line 562 
Line 563 
         char ch, *iptr;          char ch, *iptr;
         int change, i;          int change, i;
         struct pollfd pfd[1];          struct pollfd pfd[1];
         uid_t uid, huid;  
         static char command_chars[] = "\f qh?en#sdkriIuSopCHg+P1";          static char command_chars[] = "\f qh?en#sdkriIuSopCHg+P1";
   
         /*          /*
Line 803 
Line 803 
                                         ps.uid = (uid_t)-1;                                          ps.uid = (uid_t)-1;
                                         ps.huid = (uid_t)-1;                                          ps.huid = (uid_t)-1;
                                 } else if (tempbuf[0] == '-') {                                  } else if (tempbuf[0] == '-') {
                                         if ((huid = userid(tempbuf+1)) == (uid_t)-1) {                                          if (uid_from_user(tempbuf+1, &ps.huid) == -1) {
                                                 new_message(MT_standout,                                                  new_message(MT_standout,
                                                     " %s: unknown user", tempbuf+1);                                                      " %s: unknown user", tempbuf+1);
                                                 no_command = Yes;                                                  no_command = Yes;
                                         } else {                                          } else {
                                                 ps.huid = huid;  
                                                 ps.uid = (uid_t)-1;                                                  ps.uid = (uid_t)-1;
                                         }                                          }
                                 } else if ((uid = userid(tempbuf)) == (uid_t)-1) {                                  } else if (uid_from_user(tempbuf, &ps.uid) == -1) {
                                                 new_message(MT_standout,                                                  new_message(MT_standout,
                                                     " %s: unknown user", tempbuf);                                                      " %s: unknown user", tempbuf);
                                                 no_command = Yes;                                                  no_command = Yes;
                                 } else {                                  } else {
                                         ps.uid = uid;  
                                         ps.huid = (uid_t)-1;                                          ps.huid = (uid_t)-1;
                                 }                                  }
                                 putr();                                  putr();

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.92