put load average in a separate window; make idle process be
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 3 Oct 1983 13:31:55 +0000 (05:31 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 3 Oct 1983 13:31:55 +0000 (05:31 -0800)
named <idle> (instead of using name field)

SCCS-vsn: usr.bin/systat/main.c 1.5

usr/src/usr.bin/systat/main.c

index c3d747c..94179b4 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)main.c     1.4 (Lucasfilm) %G%";
+static char sccsid[] = "@(#)main.c     1.5 (Lucasfilm) %G%";
 #endif
 
 #include "systat.h"
 #endif
 
 #include "systat.h"
@@ -21,6 +21,8 @@ int     die();
 int     display();
 int     suspend();
 
 int     display();
 int     suspend();
 
+static WINDOW *wload;                  /* one line window for load average */
+
 main(argc, argv)
         int argc;
         char **argv;
 main(argc, argv)
         int argc;
         char **argv;
@@ -75,10 +77,10 @@ main(argc, argv)
         signal(SIGTERM, die);
 
         /*
         signal(SIGTERM, die);
 
         /*
-        * Initialize display.  Load average appears in standard
-        * window with current display's overlapping sub-window
-        * maintained by the display routines to minimize update
-        * work by curses.
+        * Initialize display.  Load average appears in a one line
+        * window of its own.  Current command's display appears in
+        * an overlapping sub-window of stdscr configured by the display
+        * routines to minimize update work by curses.
         */
         initscr();
        wnd = (*curcmd->c_open)();
         */
         initscr();
        wnd = (*curcmd->c_open)();
@@ -86,6 +88,11 @@ main(argc, argv)
                fprintf(stderr, "Couldn't initialize display.\n");
                die();
        }
                fprintf(stderr, "Couldn't initialize display.\n");
                die();
        }
+       wload = newwin(1, 0, 3, 20);
+       if (wload == NULL) {
+               fprintf(stderr, "Couldn't set up load average window.\n");
+               die();
+       }
 
 #ifdef notdef
         gethostname(hostname, sizeof (hostname));
 
 #ifdef notdef
         gethostname(hostname, sizeof (hostname));
@@ -98,8 +105,11 @@ main(argc, argv)
         labels();
 
         known[0].k_uid = -1;
         labels();
 
         known[0].k_uid = -1;
-        strcpy(known[0].k_name, "<idle>");
+       known[0].k_name[0] = '\0';
         numknown = 1;
         numknown = 1;
+       procs[0].pid = -1;
+       strcpy(procs[0].cmd, "<idle>");
+       numprocs = 1;
         dellave = 0.0;
 
         signal(SIGALRM, display);
         dellave = 0.0;
 
         signal(SIGALRM, display);
@@ -116,7 +126,7 @@ labels()
 
         mvaddstr(2, 20,
                 "/0   /1   /2   /3   /4   /5   /6   /7   /8   /9   /10");
 
         mvaddstr(2, 20,
                 "/0   /1   /2   /3   /4   /5   /6   /7   /8   /9   /10");
-        mvwaddstr(wnd, 0, 0, "Load Average");
+        mvaddstr(3, 5, "Load Average");
         (*curcmd->c_label)();
 #ifdef notdef
         mvprintw(21, 25, "CPU usage on %s", hostname);
         (*curcmd->c_label)();
 #ifdef notdef
         mvprintw(21, 25, "CPU usage on %s", hostname);
@@ -143,13 +153,13 @@ display()
         if (dellave < 0.1)
                 c = '|';
         dellave = lave;
         if (dellave < 0.1)
                 c = '|';
         dellave = lave;
-        wmove(wnd, 0, 15);
-        wclrtoeol(wnd);
-        for (i = (j > 50)? 50 : j; i > 0; i--)
-                waddch(wnd, c);
+        wmove(wload, 0, 0); wclrtoeol(wload);
+        for (i = (j > 50) ? 50 : j; i > 0; i--)
+                waddch(wload, c);
         if (j > 50)
         if (j > 50)
-                wprintw(wnd, " %4.1f", lave);
+                wprintw(wload, " %4.1f", lave);
         (*curcmd->c_refresh)();
         (*curcmd->c_refresh)();
+       wrefresh(wload);
         wrefresh(wnd);
         move(22, col);
         refresh();
         wrefresh(wnd);
         move(22, col);
         refresh();