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

Diff for /src/usr.bin/systat/main.c between version 1.2 and 1.3

version 1.2, 1996/04/21 23:44:05 version 1.3, 1996/05/22 11:35:35
Line 1 
Line 1 
 /*      $NetBSD: main.c,v 1.7 1996/03/21 18:04:25 jtc Exp $     */  /*      $NetBSD: main.c,v 1.8 1996/05/10 23:16:36 thorpej Exp $ */
   
 /*-  /*-
  * Copyright (c) 1980, 1992, 1993   * Copyright (c) 1980, 1992, 1993
Line 43 
Line 43 
 #if 0  #if 0
 static char sccsid[] = "@(#)main.c      8.1 (Berkeley) 6/6/93";  static char sccsid[] = "@(#)main.c      8.1 (Berkeley) 6/6/93";
 #endif  #endif
 static char rcsid[] = "$NetBSD: main.c,v 1.7 1996/03/21 18:04:25 jtc Exp $";  static char rcsid[] = "$NetBSD: main.c,v 1.8 1996/05/10 23:16:36 thorpej Exp $";
 #endif /* not lint */  #endif /* not lint */
   
 #include <sys/param.h>  #include <sys/param.h>
Line 53 
Line 53 
 #include <signal.h>  #include <signal.h>
 #include <stdio.h>  #include <stdio.h>
 #include <string.h>  #include <string.h>
   #include <unistd.h>
   
 #include "systat.h"  #include "systat.h"
 #include "extern.h"  #include "extern.h"
Line 68 
Line 69 
 static int     dellave;  static int     dellave;
   
 kvm_t *kd;  kvm_t *kd;
   char    *memf = NULL;
   char    *nlistf = NULL;
 sig_t   sigtstpdfl;  sig_t   sigtstpdfl;
 double avenrun[3];  double avenrun[3];
 int     col;  int     col;
Line 82 
Line 85 
   
 static  WINDOW *wload;                  /* one line window for load average */  static  WINDOW *wload;                  /* one line window for load average */
   
   static void usage();
   
 int  int
 main(argc, argv)  main(argc, argv)
         int argc;          int argc;
         char **argv;          char **argv;
 {  {
           int ch;
         char errbuf[80];          char errbuf[80];
   
         argc--, argv++;          while ((ch = getopt(argc, argv, "M:N:w:")) != EOF)
                   switch(ch) {
                   case 'M':
                           memf = optarg;
                           break;
                   case 'N':
                           nlistf = optarg;
                           break;
                   case 'w':
                           if ((naptime = atoi(optarg)) <= 0)
                                   errx(1, "interval <= 0.");
                           break;
                   case '?':
                   default:
                           usage();
                   }
           argc -= optind;
           argv += optind;
           /*
            * Discard setgid privileges if not the running kernel so that bad
            * guys can't print interesting stuff from kernel memory.
            */
           if (nlistf != NULL || memf != NULL)
                   setgid(getgid());
   
         while (argc > 0) {          while (argc > 0) {
                 if (argv[0][0] == '-') {                  if (isdigit(argv[0][0])) {
                           naptime = atoi(argv[0]);
                           if (naptime <= 0)
                                   naptime = 5;
                   } else {
                         struct cmdtab *p;                          struct cmdtab *p;
   
                         p = lookup(&argv[0][1]);                          p = lookup(&argv[0][0]);
                         if (p == (struct cmdtab *)-1)                          if (p == (struct cmdtab *)-1)
                                 errx(1, "ambiguous request: %s", &argv[0][1]);                                  errx(1, "ambiguous request: %s", &argv[0][0]);
                         if (p == 0)                          if (p == 0)
                                 errx(1, "unknown request: %s", &argv[0][1]);                                  errx(1, "unknown request: %s", &argv[0][0]);
                         curcmd = p;                          curcmd = p;
                 } else {  
                         naptime = atoi(argv[0]);  
                         if (naptime <= 0)  
                                 naptime = 5;  
                 }                  }
                 argc--, argv++;                  argc--, argv++;
         }          }
         kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);          kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
         if (kd == NULL) {          if (kd == NULL) {
                 error("%s", errbuf);                  error("%s", errbuf);
                 exit(1);                  exit(1);
Line 161 
Line 191 
         keyboard();          keyboard();
         /*NOTREACHED*/          /*NOTREACHED*/
 }  }
   
   static void
   usage()
   {
           fprintf(stderr, "usage: systat [-M core] [-N system] [-w wait]\n");
           exit(1);
   }
   
   
 void  void
 labels()  labels()

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3