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

Diff for /src/usr.bin/w/w.c between version 1.40 and 1.41

version 1.40, 2003/11/26 00:31:27 version 1.41, 2004/01/08 18:14:51
Line 105 
Line 105 
 struct  entry {  struct  entry {
         struct  entry *next;          struct  entry *next;
         struct  utmp utmp;          struct  utmp utmp;
         dev_t   tdev;           /* dev_t of terminal */          dev_t   tdev;                   /* dev_t of terminal */
         time_t  idle;           /* idle time of terminal in seconds */          time_t  idle;                   /* idle time of terminal in seconds */
         struct  kinfo_proc *kp; /* `most interesting' proc */          struct  kinfo_proc2 *kp;        /* `most interesting' proc */
 } *ep, *ehead = NULL, **nextp = &ehead;  } *ep, *ehead = NULL, **nextp = &ehead;
   
 static void      pr_args(struct kinfo_proc *);  static void      pr_args(struct kinfo_proc2 *);
 static void      pr_header(time_t *, int);  static void      pr_header(time_t *, int);
 static struct stat  static struct stat
                 *ttystat(char *);                  *ttystat(char *);
Line 120 
Line 120 
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
         extern char *__progname;          extern char *__progname;
         struct kinfo_proc *kp;          struct kinfo_proc2 *kp;
         struct hostent *hp;          struct hostent *hp;
         struct stat *stp;          struct stat *stp;
         FILE *ut;          FILE *ut;
Line 233 
Line 233 
 #define WUSED   (sizeof(HEADER) - sizeof("WHAT"))  #define WUSED   (sizeof(HEADER) - sizeof("WHAT"))
         (void)puts(HEADER);          (void)puts(HEADER);
   
         if ((kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nentries)) == NULL)          kp = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(*kp), &nentries);
           if (kp == NULL)
                 errx(1, "%s", kvm_geterr(kd));                  errx(1, "%s", kvm_geterr(kd));
         for (i = 0; i < nentries; i++, kp++) {          for (i = 0; i < nentries; i++, kp++) {
                 struct proc *p = &kp->kp_proc;                  if (kp->p_stat == SIDL || kp->p_stat == SZOMB)
                 struct eproc *e;  
   
                 if (p->p_stat == SIDL || p->p_stat == SZOMB)  
                         continue;                          continue;
                 e = &kp->kp_eproc;  
                 for (ep = ehead; ep != NULL; ep = ep->next) {                  for (ep = ehead; ep != NULL; ep = ep->next) {
                         /* ftp is a special case. */                          /* ftp is a special case. */
                         if (strncmp(ep->utmp.ut_line, "ftp", 3) == 0) {                          if (strncmp(ep->utmp.ut_line, "ftp", 3) == 0) {
Line 252 
Line 249 
                                     sizeof(pidstr) - 1);                                      sizeof(pidstr) - 1);
                                 pidstr[sizeof(pidstr) - 1] = '\0';                                  pidstr[sizeof(pidstr) - 1] = '\0';
                                 fp = (pid_t)strtol(pidstr, NULL, 10);                                  fp = (pid_t)strtol(pidstr, NULL, 10);
                                 if (p->p_pid == fp) {                                  if (kp->p_pid == fp) {
                                         ep->kp = kp;                                          ep->kp = kp;
                                         break;                                          break;
                                 }                                  }
                         } else if (ep->tdev == e->e_tdev &&                          } else if (ep->tdev == kp->p_tdev &&
                             e->e_pgid == e->e_tpgid) {                              kp->p__pgid == kp->p_tpgid) {
                                 /*                                  /*
                                  * Proc is in foreground of this terminal                                   * Proc is in foreground of this terminal
                                  */                                   */
                                 if (proc_compare(&ep->kp->kp_proc, p))                                  if (proc_compare(ep->kp, kp))
                                         ep->kp = kp;                                          ep->kp = kp;
                                 break;                                  break;
                         }                          }
Line 342 
Line 339 
 }  }
   
 static void  static void
 pr_args(struct kinfo_proc *kp)  pr_args(struct kinfo_proc2 *kp)
 {  {
         char **argv, *str;          char **argv, *str;
         int left;          int left;
   
         if (kp == NULL)          if (kp == NULL)
                 goto nothing;                  goto nothing;           /* XXX - can this happen? */
         left = argwidth;          left = argwidth;
         argv = kvm_getargv(kd, kp, argwidth+60);  /* +60 for ftpd snip */          argv = kvm_getargv2(kd, kp, argwidth+60);  /* +60 for ftpd snip */
         if (argv == NULL)          if (argv == NULL)
                 goto nothing;                  goto nothing;
   
         if (*argv == NULL || **argv == '\0') {          if (*argv == NULL || **argv == '\0') {
                 /* Process has zeroed argv[0], display executable name. */                  /* Process has zeroed argv[0], display executable name. */
                 fmt_putc('(', &left);                  fmt_putc('(', &left);
                 fmt_puts(kp->kp_proc.p_comm, &left);                  fmt_puts(kp->p_comm, &left);
                 fmt_putc(')', &left);                  fmt_putc(')', &left);
         }          }
         while (*argv) {          while (*argv) {

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41